generated from digitalcredentials/isomorphic-lib-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
29 lines (25 loc) · 791 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { build } from './src/app.js'
import { getConfig, initializeConfig } from './src/config.js'
import https from 'https'
import http from 'http'
import fs from 'fs'
import logger from './src/utils/logger.js'
const run = async () => {
await initializeConfig()
const { port, enableHttpsForDev } = getConfig()
const app = await build()
if (enableHttpsForDev) {
https
.createServer(
{
key: fs.readFileSync('server-dev-only.key'),
cert: fs.readFileSync('server-dev-only.cert')
},
app
).listen(port, () => logger.info(`Server started and running on port ${port} with https`))
} else {
http
.createServer(app).listen(port, () => logger.info(`Server started and running on port ${port} with http`))
}
}
run()