-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (20 loc) · 767 Bytes
/
Copy pathserver.js
File metadata and controls
22 lines (20 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { createServer } = require('http');
const { parse } = require('url');
const next = require('next');
const { port } = require('./config');
const dev = process.env.TEAMHUB_ENV !== 'production';
const nextapp = next({ dev });
const data = require('./backend/data/index');
const handle = nextapp.getRequestHandler();
nextapp.prepare().then(async () => {
await data.init();
createServer((req, res) => {
// Be sure to pass `true` as the second argument to `url.parse`.
// This tells it to parse the query portion of the URL.
const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl);
}).listen(port, (err) => {
if (err) throw err;
console.log(`> Ready on http://localhost:${port}`);
});
});