Fix typos and define handler in TSy way
This commit is contained in:
parent
37d6cd848d
commit
3160923f7e
@ -1,11 +1,11 @@
|
|||||||
import { log, timedExecution } from '$lib';
|
import { log, timedExecution } from '$lib';
|
||||||
import { validate, v7 as uuidv7 } from 'uuid';
|
import { validate, v7 as uuidv7 } from 'uuid';
|
||||||
|
import type { Handle } from '@sveltejs/kit';
|
||||||
|
|
||||||
const requestIdHeader = 'x-request-id';
|
const requestIdHeader = 'x-request-id';
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Handle} */
|
export const handle: Handle = async ({ event, resolve }) => {
|
||||||
export async function handle({ event, resolve }) {
|
// use incoming requestId, if it is a valid uuid, else generate one
|
||||||
// use incomming requestId, if it is a valid uuid, else generate one
|
|
||||||
const reqIdFromRequest = event.request.headers.get(requestIdHeader);
|
const reqIdFromRequest = event.request.headers.get(requestIdHeader);
|
||||||
const { requestId, fromRequest } =
|
const { requestId, fromRequest } =
|
||||||
reqIdFromRequest && validate(reqIdFromRequest)
|
reqIdFromRequest && validate(reqIdFromRequest)
|
||||||
@ -20,7 +20,7 @@ export async function handle({ event, resolve }) {
|
|||||||
clientIP: event.getClientAddress(),
|
clientIP: event.getClientAddress(),
|
||||||
};
|
};
|
||||||
if (fromRequest) {
|
if (fromRequest) {
|
||||||
log.trace(context, 'using incomming request-id');
|
log.trace(context, 'using incoming request-id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// make requestId available to handlers
|
// make requestId available to handlers
|
||||||
@ -42,4 +42,4 @@ export async function handle({ event, resolve }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
};
|
||||||
|
Reference in New Issue
Block a user