mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 07:47:50 +01:00
updates for deployment
This commit is contained in:
@@ -34,13 +34,15 @@ The application prioritizes responsiveness. A key scenario would be when a group
|
|||||||
|
|
||||||
## Tech Stack
|
## Tech Stack
|
||||||
|
|
||||||
This is a Node.js application. It is written purely using JavaScript/HTML/CSS. The main dependencies are
|
This is a Node.js application. It is written purely using JavaScript/HTML/CSS. The index dependencies are
|
||||||
<a href="https://expressjs.com/">Express.js</a> and <a href="https://socket.io/">Socket.io</a>. It is currently cloud hosted using the <a href='https://cloud.google.com/appengine'>Google App Engine</a>.
|
<a href="https://expressjs.com/">Express.js</a> and <a href="https://socket.io/">Socket.io</a>. It is currently cloud hosted using the <a href='https://cloud.google.com/appengine'>Google App Engine</a>.
|
||||||
|
|
||||||
## Contributing and Developers' Guide
|
## Contributing and Developers' Guide
|
||||||
|
|
||||||
### Running Locally
|
### Running Locally
|
||||||
|
|
||||||
|
The entrypoint for the application is in `index.js` at the root.
|
||||||
|
|
||||||
If you haven't already, install <a href="https://nodejs.org/en/">Node.js.</a> This should include the node package
|
If you haven't already, install <a href="https://nodejs.org/en/">Node.js.</a> This should include the node package
|
||||||
manager, <a href="https://www.npmjs.com/">npm</a>.
|
manager, <a href="https://www.npmjs.com/">npm</a>.
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ const express = require('express');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const app = express();
|
const app = express();
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const GameManager = require('./modules/GameManager.js');
|
const GameManager = require('./server/modules/GameManager.js');
|
||||||
const globals = require('./config/globals');
|
const globals = require('./server/config/globals');
|
||||||
const ServerBootstrapper = require('./modules/ServerBootstrapper');
|
const ServerBootstrapper = require('./server/modules/ServerBootstrapper');
|
||||||
|
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(bodyParser.urlencoded({
|
app.use(bodyParser.urlencoded({
|
||||||
@@ -15,14 +15,14 @@ app.use(bodyParser.urlencoded({
|
|||||||
|
|
||||||
const args = ServerBootstrapper.processCLIArgs();
|
const args = ServerBootstrapper.processCLIArgs();
|
||||||
|
|
||||||
const logger = require('./modules/Logger')(args.logLevel);
|
const logger = require('./server/modules/Logger')(args.logLevel);
|
||||||
logger.info('LOG LEVEL IS: ' + args.logLevel);
|
logger.info('LOG LEVEL IS: ' + args.logLevel);
|
||||||
|
|
||||||
const main = ServerBootstrapper.createServerWithCorrectHTTPProtocol(app, args.useHttps, args.port, logger);
|
const index = ServerBootstrapper.createServerWithCorrectHTTPProtocol(app, args.useHttps, args.port, logger);
|
||||||
|
|
||||||
app.set('port', args.port);
|
app.set('port', parseInt(process.env.PORT) || args.port || 8080);
|
||||||
|
|
||||||
const inGameSocketServer = ServerBootstrapper.createSocketServer(main, app, args.port, logger);
|
const inGameSocketServer = ServerBootstrapper.createSocketServer(index, app, args.port, logger);
|
||||||
const gameNamespace = ServerBootstrapper.createGameSocketNamespace(inGameSocketServer, logger);
|
const gameNamespace = ServerBootstrapper.createGameSocketNamespace(inGameSocketServer, logger);
|
||||||
|
|
||||||
let gameManager;
|
let gameManager;
|
||||||
@@ -42,35 +42,35 @@ gameNamespace.on('connection', function (socket) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* api endpoints */
|
/* api endpoints */
|
||||||
const games = require('./api/GamesAPI');
|
const games = require('./server/api/GamesAPI');
|
||||||
app.use('/api/games', games);
|
app.use('/api/games', games);
|
||||||
|
|
||||||
/* serve all the app's pages */
|
/* serve all the app's pages */
|
||||||
app.use('/manifest.json', (req, res) => {
|
app.use('/manifest.json', (req, res) => {
|
||||||
res.sendFile(path.join(__dirname, '../manifest.json'));
|
res.sendFile(path.join(__dirname, './manifest.json'));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use('/favicon.ico', (req, res) => {
|
app.use('/favicon.ico', (req, res) => {
|
||||||
res.sendFile(path.join(__dirname, '../client/favicon_package/favicon.ico'));
|
res.sendFile(path.join(__dirname, './client/favicon_package/favicon.ico'));
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = require('./routes/router');
|
const router = require('./server/routes/router');
|
||||||
app.use('', router);
|
app.use('', router);
|
||||||
|
|
||||||
app.use('/dist', express.static(path.join(__dirname, '../client/dist')));
|
app.use('/dist', express.static(path.join(__dirname, './client/dist')));
|
||||||
|
|
||||||
// set up routing for static content that isn't being bundled.
|
// set up routing for static content that isn't being bundled.
|
||||||
app.use('/images', express.static(path.join(__dirname, '../client/src/images')));
|
app.use('/images', express.static(path.join(__dirname, './client/src/images')));
|
||||||
app.use('/styles', express.static(path.join(__dirname, '../client/src/styles')));
|
app.use('/styles', express.static(path.join(__dirname, './client/src/styles')));
|
||||||
app.use('/webfonts', express.static(path.join(__dirname, '../client/src/webfonts')));
|
app.use('/webfonts', express.static(path.join(__dirname, './client/src/webfonts')));
|
||||||
app.use('/robots.txt', (req, res) => {
|
app.use('/robots.txt', (req, res) => {
|
||||||
res.sendFile(path.join(__dirname, '../client/robots.txt'));
|
res.sendFile(path.join(__dirname, './client/robots.txt'));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(function (req, res) {
|
app.use(function (req, res) {
|
||||||
res.sendFile(path.join(__dirname, '../client/src/views/404.html'));
|
res.sendFile(path.join(__dirname, './client/src/views/404.html'));
|
||||||
});
|
});
|
||||||
|
|
||||||
main.listen(args.port, function () {
|
index.listen(app.get('port'), function () {
|
||||||
logger.info(`Starting server on port ${args.port}`);
|
logger.info(`Starting server on port ${app.get('port')}`);
|
||||||
});
|
});
|
||||||
15
package.json
15
package.json
@@ -8,18 +8,19 @@
|
|||||||
"prestart": "npm run bundle",
|
"prestart": "npm run bundle",
|
||||||
"gcp-build": "webpack --config client/webpack/webpack-prod.config.js",
|
"gcp-build": "webpack --config client/webpack/webpack-prod.config.js",
|
||||||
"build:dev": "webpack --watch --config client/webpack/webpack-dev.config.js --mode=development",
|
"build:dev": "webpack --watch --config client/webpack/webpack-dev.config.js --mode=development",
|
||||||
"start:dev": "NODE_ENV=development nodemon server/main.js",
|
"start:dev": "NODE_ENV=development nodemon index.js",
|
||||||
"start:dev:no-hot-reload": "NODE_ENV=development && node server/main.js",
|
"start:dev:no-hot-reload": "NODE_ENV=development && node index.js",
|
||||||
"start:dev:windows": "SET NODE_ENV=development && nodemon server/main.js",
|
"start:dev:windows": "SET NODE_ENV=development && nodemon index.js",
|
||||||
"start:dev:windows:no-hot-reload": "SET NODE_ENV=development && node server/main.js",
|
"start:dev:windows:no-hot-reload": "SET NODE_ENV=development && node index.js",
|
||||||
"start": "NODE_ENV=production node server/main.js -- loglevel=trace port=8080",
|
"start": "NODE_ENV=production node index.js -- loglevel=info",
|
||||||
"start:windows": "SET NODE_ENV=production && node server/main.js -- loglevel=warn port=8080",
|
"start:windows": "SET NODE_ENV=production && node index.js -- loglevel=warn port=8080",
|
||||||
"test": "jasmine && karma start --single-run --browsers ChromeHeadless karma.conf.js",
|
"test": "jasmine && karma start --single-run --browsers ChromeHeadless karma.conf.js",
|
||||||
"test:unit": "jasmine",
|
"test:unit": "jasmine",
|
||||||
"test:e2e": "karma start --single-run --browsers ChromeHeadless karma.conf.js"
|
"test:e2e": "karma start --single-run --browsers ChromeHeadless karma.conf.js"
|
||||||
},
|
},
|
||||||
|
"main": "index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "14.15.3"
|
"node": ">= 14.0.0"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module.exports = function (logLevel = globals.LOG_LEVEL.INFO) {
|
|||||||
|| logLevel === globals.LOG_LEVEL.WARN
|
|| logLevel === globals.LOG_LEVEL.WARN
|
||||||
|| logLevel === globals.LOG_LEVEL.DEBUG
|
|| logLevel === globals.LOG_LEVEL.DEBUG
|
||||||
|| logLevel === globals.LOG_LEVEL.ERROR
|
|| logLevel === globals.LOG_LEVEL.ERROR
|
||||||
) { return; }
|
) return;
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
console.error('TRACE ', now.toGMTString(), ': ', message);
|
console.error('TRACE ', now.toGMTString(), ': ', message);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const ServerBootstrapper = {
|
|||||||
.map((arg) => {
|
.map((arg) => {
|
||||||
return /port=(\d+)/.exec(arg)[1];
|
return /port=(\d+)/.exec(arg)[1];
|
||||||
})[0] || 5000;
|
})[0] || 5000;
|
||||||
const logLevel = process.env.LOG_LEVEL || args
|
const logLevel = args
|
||||||
.filter((arg) => {
|
.filter((arg) => {
|
||||||
return /loglevel=[a-zA-Z]+/.test(arg);
|
return /loglevel=[a-zA-Z]+/.test(arg);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user