Browse Source

feat: Configurable frontend/backend ports

Owen Diffey 4 years ago
parent
commit
95df76decd

+ 3 - 2
backend/config/template.json

@@ -1,7 +1,8 @@
 {
+	"backendPort": 8080,
 	"fancyConsole": true,
 	"mongo": {
-		"url": ""
+		"url": "mongodb://USER:PASSWORD@localhost:27017/DATABASE"
 	},
 	"passcode": "Secret"
-}
+}

+ 2 - 2
backend/logic/io/index.js

@@ -64,8 +64,8 @@ module.exports = class extends coreClass {
 				});
 			});
 
-			server.listen(8080, function(){
-				console.log('listening on *:8080');
+			server.listen(config.get("backendPort"), function(){
+				console.log('listening on *:' + config.get("backendPort"));
 
 				resolve();
 			});

+ 3 - 1
frontend/dist/config/template.json

@@ -1,3 +1,5 @@
 {
+	"frontendPort": 80,
+	"frontendDomain": "http://localhost",
 	"backendUrl": "http://localhost:8080"
-}
+}

+ 1 - 0
frontend/package.json

@@ -7,6 +7,7 @@
     "@babel/core": "^7.6.2",
     "@babel/plugin-syntax-dynamic-import": "^7.2.0",
     "babel-loader": "^8.0.6",
+    "config": "^3.2.2",
     "css-loader": "^3.2.0",
     "html-webpack-plugin": "^3.2.0",
     "node-sass": "^4.12.0",

+ 5 - 2
frontend/webpack.js

@@ -1,3 +1,6 @@
+process.env.NODE_CONFIG_DIR = `${__dirname}/dist/config/`;
+const config = require("config");
+
 const VueLoaderPlugin = require("vue-loader/lib/plugin");
 const WebpackMd5Hash = require("webpack-md5-hash");
 const HtmlWebpackPlugin = require("html-webpack-plugin");
@@ -50,8 +53,8 @@ module.exports = {
 		contentBase: "./dist/",
 		historyApiFallback: true,
 		hot: true,
-		port: 80,
-		public: "http://localhost",
+		port: config.get("frontendPort"),
+		public: config.get("frontendDomain"),
 		watchOptions: {
 			aggregateTimeout: 300,
 			poll: 1000