-
From https://elysiajs.com/essential/context.html#store it is not completely clear whether Case in point: Suppose I would like to time response times with something like this... export const requestLogging = new Elysia()
.state('requestStart', 0)
.onRequest(({store}) => {
store.requestStart = Bun.nanoseconds()
})
.onResponse({as: 'global'}, ({request, set, store}) => {
const url = new URL(request.url)
const duration = formatDuration(Bun.nanoseconds() - store.requestStart)
requestLogger.debug(
chalk.grey('HTTP'), request.method, `${url.pathname}${url.search}`,
chalk.grey('→ HTTP'), set.status, chalk.gray(`[${duration}]`))
}) What happens if two requests are overlapping and handled concurrently? Would the second request overwrite |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
state
anddecorate
is global as stated in https://elysiajs.com/essential/handler.html#stateresolve
andderive
is per request as stated in https://elysiajs.com/essential/handler.html#derive