mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 03:34:35 +00:00
Merge pull request #14 from sasjs/https-production-server
chore: added https server for production
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
"main": "./src/server.ts",
|
"main": "./src/server.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "nodemon ./src/server.ts",
|
"start": "nodemon ./src/server.ts",
|
||||||
|
"start:prod": "nodemon ./src/prod-server.ts",
|
||||||
"build": "rimraf build && tsc",
|
"build": "rimraf build && tsc",
|
||||||
"semantic-release": "semantic-release -d",
|
"semantic-release": "semantic-release -d",
|
||||||
"prepare": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true",
|
"prepare": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true",
|
||||||
|
|||||||
19
src/prod-server.ts
Normal file
19
src/prod-server.ts
Normal file
@@ -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}`
|
||||||
|
)
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user