Skip to content
Snippets Groups Projects
Commit 74a79530 authored by atm2g19's avatar atm2g19
Browse files

updated security

parent ab178829
No related branches found
No related tags found
No related merge requests found
dbconf.json
dst/ dst/
node_modules/ node_modules/
launch.json launch.json
...@@ -12,3 +11,4 @@ public/**/tsconfig.json ...@@ -12,3 +11,4 @@ public/**/tsconfig.json
nodemon.json nodemon.json
public/js/p5/.DS_Store public/js/p5/.DS_Store
public/js/p5/README.txt public/js/p5/README.txt
.security/
\ No newline at end of file
This diff is collapsed.
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
"description": "node-based backend and frontend for web-games", "description": "node-based backend and frontend for web-games",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
"run": "export PORT=80; node server.js", "run": "export PORT=443; node server.js",
"test": "export PORT=8080; export DEBUG=1; node server.js" "test": "export PORT=8443; export DEBUG=1; node server.js"
}, },
"author": "Alex Mansfield", "author": "Alex Mansfield",
"license": "ISC", "license": "ISC",
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"@types/socket.io": "^2.1.4", "@types/socket.io": "^2.1.4",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"express": "^4.17.1", "express": "^4.17.1",
"express-force-ssl": "^0.3.2",
"multer": "^1.4.2", "multer": "^1.4.2",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"path": "^0.12.7", "path": "^0.12.7",
......
...@@ -60,7 +60,7 @@ const DB = { ...@@ -60,7 +60,7 @@ const DB = {
} }
} }
const MYSQL_CONFIG: mysql.ConnectionConfig = JSON.parse(readFileSync("./dbconf.json").toString()); const MYSQL_CONFIG: mysql.ConnectionConfig = JSON.parse(readFileSync(".security/dbconf.json").toString());
const Games: GameDB = new GameDB(MYSQL_CONFIG); const Games: GameDB = new GameDB(MYSQL_CONFIG);
// POOL.getConnection((err) => { // POOL.getConnection((err) => {
......
import * as express from "express"; import * as express from "express";
import {AutoRedirect as autoredir} from "./autoredirect" import {
import {Log} from "./log" AutoRedirect as autoredir
} from "./autoredirect"
import {
Log
} from "./log"
import * as error from "./error" import * as error from "./error"
import {staticServe as serve} from "./sendFile" import {
import {game_api} from "./games" staticServe as serve
} from "./sendFile"
import {
game_api
} from "./games"
import * as bodyParser from "body-parser"; import * as bodyParser from "body-parser";
import multer = require("multer"); import multer = require("multer");
import {
forceSSL
//@ts-ignore
} from "express-force-ssl"
import {
readFileSync
} from "fs";
import {
createServer
} from "https";
const upload = multer(); const upload = multer();
const app: express.Application = express(); const app: express.Application = express();
const PORT: number = parseInt(process.env.PORT) || 8080; const PORT: number = parseInt(process.env.PORT) || 8080;
let server = app.listen(PORT, () => {console.log(`Listening on port ${PORT}`)}); const SSL_OPTS = {
const GAMES = game_api(server); key: readFileSync(".security/origin.priv"),
cert: readFileSync(".security/origin.pem"),
}
let secServ = createServer(SSL_OPTS, app);
secServ.listen(PORT, () => {
console.log(`listening on port:${PORT}`);
});
// let server = app.listen(PORT, () => {
// console.log(`Listening on port ${PORT}`)
// });
const GAMES = game_api(secServ);
app.use(bodyParser.json()); app.use(bodyParser.json());
// app.post('*', upload.array()) // app.post('*', upload.array())
...@@ -31,5 +62,3 @@ app.get("*", serve("public/")); ...@@ -31,5 +62,3 @@ app.get("*", serve("public/"));
app.use(error.error); app.use(error.error);
app.use(error.handled_error); app.use(error.handled_error);
app.use(error.unhandled_error); app.use(error.unhandled_error);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment