git ssb

0+

Rômulo Alves / website



Tree: 05da29162cd94001b87a1366246df608c8a7fa4d

Files: 05da29162cd94001b87a1366246df608c8a7fa4d / server.js

887 bytesRaw
1const { createServer } = require('http');
2const { parse } = require('url');
3const { createReadStream } = require('fs');
4const { join } = require('path');
5const next = require('next');
6
7
8const port = parseInt(process.env.PORT, 10) || 3000;
9const dev = process.env.NODE_ENV !== 'production';
10const app = next({ dev });
11const handle = app.getRequestHandler();
12
13app.prepare()
14 .then(() => {
15 createServer((req, res) => {
16 const parsedUrl = parse(req.url, true);
17 const { pathname, query } = parsedUrl;
18
19 if (pathname === '/.well-known/dat') {
20 res.writeHead(200, { 'Content-Type': 'text/plain' });
21
22 return createReadStream(join(__dirname, pathname)).pipe(res);
23 }
24
25 return handle(req, res, parsedUrl);
26 }).listen(port, err => {
27 if (err) {
28 throw err;
29 }
30
31 console.log(`> Ready on http://localhost:${port}`);
32 });
33 });

Built with git-ssb-web