mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
fix promise type problem, include emoji
This commit is contained in:
parent
eaf361c31d
commit
347e4b6599
@ -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}`)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user