From 0c507fd33baa54fbed77b39f34c0b49a13b7a390 Mon Sep 17 00:00:00 2001 From: Darius Rapalis Date: Sun, 30 Jan 2022 12:00:23 +0200 Subject: [PATCH] loading port from config file --- .gitignore | 3 ++- src/app.ts | 5 +++-- src/config.json | 3 +++ tsconfig.json | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 src/config.json diff --git a/.gitignore b/.gitignore index ce72288..f4241ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode .idea node_modules -dist \ No newline at end of file +dist +src/config.json \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index c7dae12..17d80c0 100644 --- a/src/app.ts +++ b/src/app.ts @@ -4,6 +4,7 @@ import { Socket } from "socket.io"; import { Player } from "./player"; import { PlayerList } from "./playerList"; import { MapTile } from "./mapTile"; +import * as config from './config.json'; const app: express.Application = express(); @@ -278,6 +279,6 @@ io.on("connect", (socket: Socket) => { // }); // }); -server.listen(3000, () => { - console.log("listening on *:3000"); +server.listen(config.port || 3000, () => { + console.log("listening on *:" + (config.port || 3000)); }); diff --git a/src/config.json b/src/config.json new file mode 100644 index 0000000..d0cc5c0 --- /dev/null +++ b/src/config.json @@ -0,0 +1,3 @@ +{ + "port": 3000 +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index ee6fda6..52851b5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -46,7 +46,8 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "resolveJsonModule": true // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */