-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (44 loc) · 1.34 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import fs from 'fs'
import spdy from'spdy'
import http from 'http'
import https from 'https'
import { createServer } from 'http'
import app from './server'
//ssl credentials
// const privateKey = fs.readFileSync('sslcert/server.key', 'utf8');
// const certificate = fs.readFileSync('sslcert/server.crt', 'utf8');
// const credentials = { key: privateKey, cert: certificate };
// const httpServer = http.createServer(app)
// const httpsServer = spdy
// .createServer(credentials, app)
// .listen(3005, (error) => {
// if (error) {
// console.error(error)
// return process.exit(1)
// } else {
// console.log('Listening on port:3005 ')
// }
// })
// let currentApp = app
// httpServer.listen(3006, () => {
// console.log('Server listening on port 3006')
// })
// if (module.hot) {
// module.hot.accept(['./server'], () => {
// httpsServer.removeListener('request', currentApp)
// httpsServer.on('request', app)
// currentApp = app
// })
// }
const server = http.createServer(app)
let currentApp = app
server.listen(3000, () => {
console.log('Server listening on port 3000')
})
if (module.hot) {
module.hot.accept(['./server'], () => {
server.removeListener('request', currentApp)
server.on('request', app)
currentApp = app
})
}