2020-04-19 16:38:07 +02:00
|
|
|
const { getArgs } = require("./utils");
|
|
|
|
const startFrontendDevServer = require("./server-frontend-dev");
|
|
|
|
const startBackendServer = require("./server-backend");
|
|
|
|
|
|
|
|
const SERVER_MODES = {
|
|
|
|
PRODUCTION: 1,
|
|
|
|
DEVELOPMENT: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
const args = getArgs();
|
|
|
|
|
2020-04-20 11:03:07 +02:00
|
|
|
if ( typeof args.mode === "undefined") {
|
|
|
|
// default to production mode
|
|
|
|
args.mode = "production";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args.mode !== "production" && args.mode !== "development") {
|
|
|
|
throw new Error("--mode can only be 'development' or 'production'")
|
2020-04-19 16:38:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const server_mode = args.mode === "production" ? SERVER_MODES.PRODUCTION : SERVER_MODES.DEVELOPMENT;
|
|
|
|
|
|
|
|
if (server_mode === SERVER_MODES.DEVELOPMENT){
|
|
|
|
console.info("Starting server in development mode.");
|
|
|
|
startFrontendDevServer(8080);
|
2020-04-19 18:14:44 +02:00
|
|
|
// this time, it's the frontend server that is on port 8080
|
|
|
|
// requests for the backend will be proxied to prevent cross origins errors
|
2020-04-19 16:38:07 +02:00
|
|
|
startBackendServer(3000);
|
|
|
|
} else {
|
|
|
|
console.info("Starting server in production mode.");
|
|
|
|
startBackendServer(8080);
|
|
|
|
}
|