fix promise type problem, include emoji

This commit is contained in:
Ulf Gebhardt 2023-12-14 01:15:54 +01:00
parent eaf361c31d
commit 347e4b6599
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -52,27 +52,28 @@ async function startServer() {
// Vike middleware. It should always be our last middleware (because it's a
// catch-all middleware superseding any middleware placed after it).
// eslint-disable-next-line @typescript-eslint/no-misused-promises
app.get('*', async (req, res, next) => {
const pageContextInit = {
urlOriginal: req.originalUrl,
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
if (!httpResponse) {
return next()
} else {
const { body, statusCode, headers, earlyHints } = httpResponse
if (res.writeEarlyHints) res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
headers.forEach(([name, value]) => res.setHeader(name, value))
res.status(statusCode)
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/stream
res.send(body)
}
app.get('*', (req, res, next) => {
void (async (req, res, next) => {
const pageContextInit = {
urlOriginal: req.originalUrl,
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
if (!httpResponse) {
next()
} else {
const { body, statusCode, headers, earlyHints } = httpResponse
if (res.writeEarlyHints) res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
headers.forEach(([name, value]) => res.setHeader(name, value))
res.status(statusCode)
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/stream
res.send(body)
}
})(req, res, next)
})
const port = process.env.PORT || 3000
app.listen(port)
// eslint-disable-next-line no-console
console.log(`Server running at http://localhost:${port}`)
console.log(`🚀 Server running at http://localhost:${port}`)
}