-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (26 loc) · 1.26 KB
/
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
30
31
32
33
34
import { readFile } from 'node:fs/promises'
import { createSecureServer } from 'node:http2'
import http from 'node:http'
// import https from 'node:https'
import chalk from 'chalk'
import config from 'config'
import { app } from './server/app.js'
const privateKey = await readFile(config.get('server.certificate.key'), 'utf8')
const certificate = await readFile(config.get('server.certificate.cert'), 'utf8')
const http2Options = {
key: privateKey,
cert: certificate,
allowHTTP1: true,
}
const httpServer = http.createServer(app)
// const httpsServer = https.createServer(credentials, app)
httpServer.listen(config.get('server.port.http'), () => {
console.log('%s App is running at https://localhost:%d in %s mode', chalk.green('✓'), config.get('server.port.http'), process.env.NODE_ENV)
})
const http2Server = createSecureServer(http2Options, app)
http2Server.listen(config.get('server.port.https'), () => {
console.log('%s App is running at https://localhost:%d in %s mode', chalk.green('✓'), config.get('server.port.https'), process.env.NODE_ENV)
})
// httpsServer.listen(config.get('server.port.https'), () => {
// console.log('%s App is running at https://localhost:%d in %s mode', chalk.green('✓'), config.get('server.port.https'), process.env.NODE_ENV)
// })