Files: f20766fcd63c17fd9526329e92ea3e92f42b26ac / server.js
838 bytesRaw
1 | const next = require('next'); |
2 | const express = require('express'); |
3 | const compression = require('compression'); |
4 | const { join } = require('path'); |
5 | |
6 | const dev = process.env.IS_DEVELOPMENT || false; |
7 | const port = process.env.PORT || 3000; |
8 | |
9 | const app = next({ dev }); |
10 | const handle = app.getRequestHandler(); |
11 | |
12 | app.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