git ssb

0+

Rômulo Alves / plainbudget-next



Tree: f20766fcd63c17fd9526329e92ea3e92f42b26ac

Files: f20766fcd63c17fd9526329e92ea3e92f42b26ac / server.js

838 bytesRaw
1const next = require('next');
2const express = require('express');
3const compression = require('compression');
4const { join } = require('path');
5
6const dev = process.env.IS_DEVELOPMENT || false;
7const port = process.env.PORT || 3000;
8
9const app = next({ dev });
10const handle = app.getRequestHandler();
11
12app.prepare()
13 .then(function() {
14 const server = express();
15
16 if (!dev) {
17 server.use(compression());
18 }
19
20 server.get('/service-worker.js', function(request, response) {
21 const filePath = join(__dirname, '.next', 'service-worker.js');
22
23 return app.serveStatic(request, response, filePath);
24 });
25
26 server.get('*', function(request, response) {
27 return handle(request, response);
28 });
29
30 server.listen(port, function() {
31 console.log(`> Ready on http://localhost:${port}`);
32 });
33 });
34

Built with git-ssb-web