Skip to content

Instantly share code, notes, and snippets.

@cj
Created November 13, 2021 16:55
Show Gist options
  • Save cj/90caa20653cf00d3bcc989af82f21f94 to your computer and use it in GitHub Desktop.
Save cj/90caa20653cf00d3bcc989af82f21f94 to your computer and use it in GitHub Desktop.
blitzjs krabs custom server
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