Fix typos and define handler in TSy way
All checks were successful
/ Misc Linters (push) Successful in 23s
/ Build App (push) Successful in 52s

This commit is contained in:
Valentin Brandl 2024-08-17 16:49:38 +02:00
parent 37d6cd848d
commit 3160923f7e
Signed by: vbrandl
GPG Key ID: CAD4DA1A789125F9

View File

@ -1,11 +1,11 @@
import { log, timedExecution } from '$lib';
import { validate, v7 as uuidv7 } from 'uuid';
import type { Handle } from '@sveltejs/kit';
const requestIdHeader = 'x-request-id';
/** @type {import('@sveltejs/kit').Handle} */
export async function handle({ event, resolve }) {
// use incomming requestId, if it is a valid uuid, else generate one
export const handle: Handle = async ({ event, resolve }) => {
// use incoming requestId, if it is a valid uuid, else generate one
const reqIdFromRequest = event.request.headers.get(requestIdHeader);
const { requestId, fromRequest } =
reqIdFromRequest && validate(reqIdFromRequest)
@ -20,7 +20,7 @@ export async function handle({ event, resolve }) {
clientIP: event.getClientAddress(),
};
if (fromRequest) {
log.trace(context, 'using incomming request-id');
log.trace(context, 'using incoming request-id');
}
// make requestId available to handlers
@ -42,4 +42,4 @@ export async function handle({ event, resolve }) {
);
return response;
}
};