Move request-id header name to $lib

This commit is contained in:
Valentin Brandl 2024-08-18 15:33:56 +02:00
parent 13b1d57e08
commit da92ed6258
Signed by: vbrandl
GPG Key ID: CAD4DA1A789125F9
2 changed files with 3 additions and 3 deletions

View File

@ -1,9 +1,7 @@
import { log, timedExecution } from '$lib'; import { log, timedExecution, requestIdHeader } from '$lib';
import { validate, v7 as uuidv7 } from 'uuid'; import { validate, v7 as uuidv7 } from 'uuid';
import type { Handle } from '@sveltejs/kit'; import type { Handle } from '@sveltejs/kit';
const requestIdHeader = 'x-request-id';
export const handle: Handle = async ({ event, resolve }) => { export const handle: Handle = async ({ event, resolve }) => {
// use incoming requestId, if it is a valid uuid, else generate one // use incoming requestId, if it is a valid uuid, else generate one
const reqIdFromRequest = event.request.headers.get(requestIdHeader); const reqIdFromRequest = event.request.headers.get(requestIdHeader);

View File

@ -29,6 +29,8 @@ if (!('STORAGE_PATH' in process.env)) {
} }
export const storagePath: string = process.env.STORAGE_PATH ?? defaultPath; export const storagePath: string = process.env.STORAGE_PATH ?? defaultPath;
export const requestIdHeader = 'x-request-id';
export default safePath; export default safePath;
export async function timedExecution<T>( export async function timedExecution<T>(