feat: implement error handling and validation middleware, enhance result handling
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
16
apps/backend/src/lib/http/request-id.ts
Normal file
16
apps/backend/src/lib/http/request-id.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { MiddlewareHandler } from 'hono'
|
||||
|
||||
type Env = {
|
||||
Variables: {
|
||||
requestId: string
|
||||
}
|
||||
}
|
||||
|
||||
export const requestIdMiddleware: MiddlewareHandler<Env> = async (c, next) => {
|
||||
const requestId = crypto.randomUUID()
|
||||
|
||||
c.set('requestId', requestId)
|
||||
c.header('X-Request-Id', requestId)
|
||||
|
||||
await next()
|
||||
}
|
||||
Reference in New Issue
Block a user