-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
38 lines (30 loc) · 864 Bytes
/
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
const { Nuxt, Builder } = require('nuxt');
const { createServer } = require('./api/centralSystem');
const http = require('http')
const fs = require('fs')
const isProd = (process.env.NODE_ENV === 'production')
const port = process.env.PORT || 3000
// We instantiate nuxt.js with the options
const config = require('./nuxt.config.js')
config.dev = !isProd
const nuxt = new Nuxt(config);
// Render every route with Nuxt.js
// Build only in dev mode with hot-reloading
if (config.dev) {
new Builder(nuxt).build()
.then(listen)
.catch((error) => {
console.error(error)
process.exit(1)
})
}
else {
listen()
}
function listen() {
const options = {};
const server = http.createServer(options, nuxt.render);
const centralSystem = createServer(server);
server.listen(port)
console.log(`Server listening on localhost:${port}`)
}