-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (32 loc) · 995 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
30
31
32
33
34
35
36
37
38
39
40
const Nuxt = require('nuxt');
const bodyParser = require('body-parser');
const session = require('express-session');
const express = require('express');
const path = require('path');
const app = express();
const logux = require('./server/logux')
app.use(bodyParser.json());
app.use(session({
secret: 'super-secret-key',
resave: false,
saveUninitialized: false,
cookie: { maxAge: 60000 }
}));
/* eslint-disable no-console */
const apiRoutes = require('./server/routes/apiRoutes.js');
app.use(express.static(path.join( __dirname, './assets')));
app.use('/api', apiRoutes);
const isProd = process.env.NODE_ENV === 'production';
let config = require('./nuxt.config.js');
config.dev = !isProd;
const nuxt = new Nuxt(config);
const promise = (isProd ? Promise.resolve() : nuxt.build());
promise.then(() => {
app.use(nuxt.render);
app.listen(3000);
console.log('Server is listening on http://localhost:3000');
})
.catch((error) => {
console.error(error);
process.exit(1);
});