From ef7811c7be00f27dc898b1791df625e271b41aa3 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Wed, 6 Oct 2021 20:06:31 +0500 Subject: [PATCH 1/2] chore: added https server for production --- package.json | 1 + src/prod-server.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/prod-server.ts diff --git a/package.json b/package.json index 2981f52..459c4e6 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "./src/server.ts", "scripts": { "start": "nodemon ./src/server.ts", + "start:prod": "nodemon ./src/prod-server.ts", "build": "rimraf build && tsc", "semantic-release": "semantic-release -d", "prepare": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true", diff --git a/src/prod-server.ts b/src/prod-server.ts new file mode 100644 index 0000000..e04c645 --- /dev/null +++ b/src/prod-server.ts @@ -0,0 +1,18 @@ +import path from 'path' +import { readFileSync } from 'fs' +import * as https from 'https' + +import app from './app' + +const port = 5001 +const keyPath = path.join('certificates', 'privkey.pem') +const certPath = path.join('certificates', 'fullchain.pem') + +const key = readFileSync(keyPath) +const cert = readFileSync(certPath) + +const httpsServer = https.createServer({ key, cert }, app) + +httpsServer.listen(port, () => { + console.log(`⚡️[server]: Server is running at https://localhost:${port}`) +}) From 4d8efbb88d32154d84e80b79780e2e3de2f519e4 Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Mon, 11 Oct 2021 16:42:17 +0300 Subject: [PATCH 2/2] fix(prod-server): use port from configuration --- src/prod-server.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/prod-server.ts b/src/prod-server.ts index e04c645..e652e39 100644 --- a/src/prod-server.ts +++ b/src/prod-server.ts @@ -1,10 +1,9 @@ import path from 'path' import { readFileSync } from 'fs' import * as https from 'https' - +import { configuration } from '../package.json' import app from './app' -const port = 5001 const keyPath = path.join('certificates', 'privkey.pem') const certPath = path.join('certificates', 'fullchain.pem') @@ -13,6 +12,8 @@ const cert = readFileSync(certPath) const httpsServer = https.createServer({ key, cert }, app) -httpsServer.listen(port, () => { - console.log(`⚡️[server]: Server is running at https://localhost:${port}`) +httpsServer.listen(configuration.sasJsPort, () => { + console.log( + `⚡️[server]: Server is running at https://localhost:${configuration.sasJsPort}` + ) })