Version bump, and cleaned up some frontend.

This commit is contained in:
Andrew Lalis 2022-05-31 13:23:24 +02:00
parent 9cb074b2ec
commit 2561c8f3d4
5 changed files with 18 additions and 35 deletions

View File

@ -21,24 +21,8 @@ const API_BUILD = "mvn clean package spring-boot:repackage -DskipTests=true";
void main(string[] args) { void main(string[] args) {
print("Building RailSignalAPI"); print("Building RailSignalAPI");
string baseDomain = "localhost:8080";
bool useHttps = false;
if (args.length >= 2) {
baseDomain = args[1];
if (args.length >= 3 && args[2] == "secure") {
useHttps = true;
print("Will configure web app to use secure connections.");
}
}
string apiUrl = format!"%s://%s/api"(useHttps ? "https" : "http", baseDomain);
string wsUrl = format!"%s://%s/api/ws/app"(useHttps ? "wss" : "ws", baseDomain);
print("Building web app using API url %s and WS url %s", apiUrl, wsUrl);
sleepSeconds(3);
chdir("quasar-app"); chdir("quasar-app");
print("Building app..."); print("Building app...");
setEnv("RAIL_SIGNAL_API_URL", apiUrl);
setEnv("RAIL_SIGNAL_WS_URL", wsUrl);
runOrQuit(APP_BUILD); runOrQuit(APP_BUILD);
print("Copying dist from %s to %s", DIST_ORIGIN, DIST); print("Copying dist from %s to %s", DIST_ORIGIN, DIST);
chdir(".."); chdir("..");
@ -49,15 +33,5 @@ void main(string[] args) {
print("Building API..."); print("Building API...");
runOrQuit(API_BUILD); runOrQuit(API_BUILD);
print("Build complete!"); print("Build complete!");
string jarFile = findFile(".", "\\.jar", false);
print("Generating run script...");
auto scriptFile = File("target/run.sh", "w");
scriptFile.write("#!/usr/bin/bash\n");
scriptFile.write("RAIL_SIGNAL_API_URL=http://localhost:8080/api\n");
scriptFile.write("RAIL_SIGNAL_WS_URL=ws://localhost:8080/api/ws/app\n");
scriptFile.write("java -jar " ~ jarFile ~ "\n");
scriptFile.close();
print("Script file generated.");
} }

View File

@ -10,7 +10,7 @@
</parent> </parent>
<groupId>nl.andrewl</groupId> <groupId>nl.andrewl</groupId>
<artifactId>rail-signal-api</artifactId> <artifactId>rail-signal-api</artifactId>
<version>2.0.0</version> <version>2.0.1</version>
<name>rail-signal-api</name> <name>rail-signal-api</name>
<description>A simple API for tracking rail traffic in signalled blocks.</description> <description>A simple API for tracking rail traffic in signalled blocks.</description>
<properties> <properties>

View File

@ -70,10 +70,10 @@ module.exports = configure(function (ctx) {
publicPath: "/app/", publicPath: "/app/",
// analyze: true, // analyze: true,
env: { // env: {
API_URL: ctx.dev ? "http://localhost:8080/api" : process.env.RAIL_SIGNAL_API_URL, // API_URL: ctx.dev ? "http://localhost:8080/api" : process.env.RAIL_SIGNAL_API_URL,
WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : process.env.RAIL_SIGNAL_WS_URL // WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : process.env.RAIL_SIGNAL_WS_URL
}, // },
// rawDefine: {} // rawDefine: {}
// ignorePublicFolder: true, // ignorePublicFolder: true,
// minify: "hidden", // minify: "hidden",

View File

@ -1,4 +1,12 @@
export const API_URL = process.env.API_URL; /*
export const WS_URL = process.env.WS_URL; In development mode, we should use localhost:8080 as that's where the API is set
console.log("Using API url: " + API_URL); to run. In production mode, this app is deployed under the same host as the API,
console.log("Using WS url: " + WS_URL); so we can simply use `location.origin` and `location.host` to define our API and
WS urls.
*/
export const API_URL = process.env.DEV
? "http://localhost:8080/api"
: location.origin + "/api";
export const WS_URL = process.env.DEV
? "ws://localhost:8080/api/ws/app"
: (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/api/ws/app";

View File

@ -33,6 +33,7 @@ public class WebsocketConfig implements WebSocketConfigurer {
.addInterceptors(componentInterceptor); .addInterceptors(componentInterceptor);
WebSocketHandlerRegistration appHandlerReg = registry.addHandler(appHandler, "/api/ws/app/*") WebSocketHandlerRegistration appHandlerReg = registry.addHandler(appHandler, "/api/ws/app/*")
.addInterceptors(appInterceptor); .addInterceptors(appInterceptor);
// appHandlerReg.setAllowedOrigins("*");
// If we're in a development profile, allow any origin to access the app websocket. // If we're in a development profile, allow any origin to access the app websocket.
// This is so that we can use a standalone JS dev server. // This is so that we can use a standalone JS dev server.
if (Set.of(env.getActiveProfiles()).contains("development")) { if (Set.of(env.getActiveProfiles()).contains("development")) {