f5b5ae51bd
* gql fix + new dependency-less status check endpoint * added correlation ids to upstream calls * added prometheus metrics * added sigint logging
16 lines
529 B
TypeScript
16 lines
529 B
TypeScript
import { defineEventHandler, fromNodeMiddleware } from 'h3'
|
|
import { IncomingMessage, ServerResponse } from 'http'
|
|
import { REQUEST_ID_HEADER } from '~~/server/lib/core/helpers/constants'
|
|
|
|
export const getRequestIdMiddleware = (
|
|
req: IncomingMessage,
|
|
res: ServerResponse,
|
|
next: () => void
|
|
) => {
|
|
// we are the ones who are pushing the req.id there, so we know its a string
|
|
res.setHeader(REQUEST_ID_HEADER, `${req.id as string}`)
|
|
next()
|
|
}
|
|
|
|
export default defineEventHandler(fromNodeMiddleware(getRequestIdMiddleware))
|