Created
November 13, 2021 16:55
-
-
Save cj/90caa20653cf00d3bcc989af82f21f94 to your computer and use it in GitHub Desktop.
blitzjs krabs custom server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import blitz from 'blitz/custom-server' | |
import { createServer } from 'http' | |
import { log } from '@blitzjs/display' | |
import krabs from 'krabs' | |
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) => { | |
// @ts-ignore | |
res.status = (code: number) => (res.statusCode = code) | |
krabs(req, res, handle, app) | |
}).listen(PORT, () => { | |
log.success(`Ready on http://localhost:${PORT}`) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment