1
0
mirror of synced 2025-12-19 18:11:23 -05:00
Files
2021-12-03 16:46:55 -05:00

26 lines
647 B
TypeScript

import blitz from "blitz/custom-server"
import {createServer} from "http"
import {parse} from "url"
import {log} from "next/dist/server/lib/logging"
const {PORT = "3000"} = process.env
const dev = process.env.NODE_ENV !== "production"
const app = blitz({dev})
const handle = app.getRequestHandler()
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url!, true)
const {pathname} = parsedUrl
if (pathname === "/hello") {
res.writeHead(200).end("world")
return
}
handle(req, res, parsedUrl)
}).listen(PORT, () => {
log.success(`Ready on http://localhost:${PORT}`)
})
})