1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-mobx-state-tree-typescript/server.ts

26 lines
708 B
TypeScript
Raw Normal View History

import { createServer } from "http";
import mobxReact from "mobx-react";
import next from "next";
import { parse } from "url";
const envPort = parseInt(process.env.PORT as string, 10) || 3000;
const dev = process.env.NODE_ENV !== "production";
mobxReact.useStaticRendering(true);
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url as string, true);
handle(req, res, parsedUrl)
.catch((error) => { throw(error); });
}).listen((port, err) => {
if (err) {
throw err;
}
console.log(`> Ready on http://localhost:${port}`);
});
}).catch((error) => { throw(error); });