From da92ed625853e97dcd521cee8433e2697f32cd8f Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sun, 18 Aug 2024 15:33:56 +0200 Subject: [PATCH] Move request-id header name to $lib --- src/hooks.server.ts | 4 +--- src/lib/index.ts | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 4c99ccb..17372c1 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,9 +1,7 @@ -import { log, timedExecution } from '$lib'; +import { log, timedExecution, requestIdHeader } from '$lib'; import { validate, v7 as uuidv7 } from 'uuid'; import type { Handle } from '@sveltejs/kit'; -const requestIdHeader = 'x-request-id'; - 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); diff --git a/src/lib/index.ts b/src/lib/index.ts index 7cee25d..c2c405a 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -29,6 +29,8 @@ if (!('STORAGE_PATH' in process.env)) { } export const storagePath: string = process.env.STORAGE_PATH ?? defaultPath; +export const requestIdHeader = 'x-request-id'; + export default safePath; export async function timedExecution(