diff --git a/package.json b/package.json index 708bbde..86c8e0f 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..e652e39 --- /dev/null +++ b/src/prod-server.ts @@ -0,0 +1,19 @@ +import path from 'path' +import { readFileSync } from 'fs' +import * as https from 'https' +import { configuration } from '../package.json' +import app from './app' + +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(configuration.sasJsPort, () => { + console.log( + `⚡️[server]: Server is running at https://localhost:${configuration.sasJsPort}` + ) +})