@logtape/elysia 2.2.0-dev.700 → 2.2.0-dev.702

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mod.cjs CHANGED
@@ -274,6 +274,17 @@ const elysiaRouteMethods = [
274
274
  "post",
275
275
  "put"
276
276
  ];
277
+ const elysiaRouteHookKeys = [
278
+ "afterHandle",
279
+ "afterResponse",
280
+ "beforeHandle",
281
+ "derive",
282
+ "error",
283
+ "mapResponse",
284
+ "parse",
285
+ "resolve",
286
+ "transform"
287
+ ];
277
288
  function getElysiaRouteEntries(plugin) {
278
289
  if (plugin == null || typeof plugin !== "object") return [];
279
290
  const routePlugin = plugin;
@@ -287,41 +298,83 @@ function getElysiaRouteEntries(plugin) {
287
298
  function wrapLocalRouteHandlers(plugin, buildAndStoreRequestContext, applyRequestContextToSet) {
288
299
  const wrappedHandlers = /* @__PURE__ */ new WeakSet();
289
300
  const wrappedHandlerCache = /* @__PURE__ */ new WeakMap();
290
- const wrapHandler = (handler) => {
291
- if (typeof handler !== "function") return handler;
292
- const routeHandler = handler;
293
- if (wrappedHandlers.has(routeHandler)) return handler;
294
- const cached = wrappedHandlerCache.get(routeHandler);
301
+ const getRouteContext = (value) => {
302
+ if (value == null || typeof value !== "object") return void 0;
303
+ const context = value;
304
+ if (!(context.request instanceof Request)) return void 0;
305
+ return value;
306
+ };
307
+ const wrapRequestCallback = (callback) => {
308
+ if (typeof callback !== "function") return callback;
309
+ const requestCallback = callback;
310
+ if (wrappedHandlers.has(requestCallback)) return callback;
311
+ const cached = wrappedHandlerCache.get(requestCallback);
295
312
  if (cached != null) return cached;
296
- const wrapped = async function(ctx) {
313
+ const wrapped = async function(...args) {
314
+ const ctx = getRouteContext(args[0]);
315
+ if (ctx == null) return await requestCallback.apply(this, args);
297
316
  const requestContext = await buildAndStoreRequestContext(ctx.request);
298
317
  ctx.store.startTime = requestContext?.startTime ?? performance.now();
299
318
  applyRequestContextToSet(ctx.set, requestContext);
300
- return await (0, __logtape_logtape.withContext)(requestContext?.context ?? {}, () => routeHandler.call(this, ctx));
319
+ return await (0, __logtape_logtape.withContext)(requestContext?.context ?? {}, () => requestCallback.apply(this, args));
301
320
  };
302
321
  wrappedHandlers.add(wrapped);
303
- wrappedHandlerCache.set(routeHandler, wrapped);
322
+ wrappedHandlerCache.set(requestCallback, wrapped);
304
323
  return wrapped;
305
324
  };
325
+ const wrapRouteHookValue = (value) => {
326
+ if (Array.isArray(value)) return value.map(wrapRouteHookValue);
327
+ if (typeof value === "function") return wrapRequestCallback(value);
328
+ if (value == null || typeof value !== "object") return value;
329
+ const hookContainer = value;
330
+ if (typeof hookContainer.fn !== "function") return value;
331
+ return {
332
+ ...hookContainer,
333
+ fn: wrapRequestCallback(hookContainer.fn)
334
+ };
335
+ };
336
+ const wrapRouteHooks = (hooks) => {
337
+ if (hooks == null || typeof hooks !== "object") return hooks;
338
+ const routeHooks = hooks;
339
+ let changed = false;
340
+ const wrappedHooks = { ...routeHooks };
341
+ for (const key of elysiaRouteHookKeys) {
342
+ const value = routeHooks[key];
343
+ const wrappedValue = wrapRouteHookValue(value);
344
+ if (wrappedValue === value) continue;
345
+ wrappedHooks[key] = wrappedValue;
346
+ changed = true;
347
+ }
348
+ return changed ? wrappedHooks : hooks;
349
+ };
306
350
  const wrapRouteEntries = (routePlugin) => {
307
351
  const restore = [];
308
352
  for (const route$1 of getElysiaRouteEntries(routePlugin)) {
309
353
  const handler = route$1.handler;
310
- const wrappedHandler = wrapHandler(handler);
311
- if (wrappedHandler === handler) continue;
312
- route$1.handler = wrappedHandler;
313
- restore.push(() => {
314
- route$1.handler = handler;
315
- });
354
+ const wrappedHandler = wrapRequestCallback(handler);
355
+ if (wrappedHandler !== handler) {
356
+ route$1.handler = wrappedHandler;
357
+ restore.push(() => {
358
+ route$1.handler = handler;
359
+ });
360
+ }
361
+ const hooks = route$1.hooks;
362
+ const wrappedHooks = wrapRouteHooks(hooks);
363
+ if (wrappedHooks !== hooks) {
364
+ route$1.hooks = wrappedHooks;
365
+ restore.push(() => {
366
+ route$1.hooks = hooks;
367
+ });
368
+ }
316
369
  }
317
370
  return restore;
318
371
  };
319
372
  for (const method of elysiaRouteMethods) {
320
373
  const register = plugin[method].bind(plugin);
321
- plugin[method] = (path, handler, hook) => register(path, wrapHandler(handler), hook);
374
+ plugin[method] = (path, handler, hook) => register(path, wrapRequestCallback(handler), wrapRouteHooks(hook));
322
375
  }
323
376
  const route = plugin.route.bind(plugin);
324
- plugin.route = (method, path, handler, hook) => route(method, path, wrapHandler(handler), hook);
377
+ plugin.route = (method, path, handler, hook) => route(method, path, wrapRequestCallback(handler), wrapRouteHooks(hook));
325
378
  const use = plugin.use.bind(plugin);
326
379
  plugin.use = (childPlugin, ...options) => {
327
380
  const restore = wrapRouteEntries(childPlugin);
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;;;AAKa,UALI,aAAA,CAKJ;EAAM,OAAA,EAJR,OAIQ;EAQP,IAAA,EAAA,MAAA;EAMA,GAAA,EAAA;IAUA,MAAA,EAAA,MAAc;IAAA,OAAA,EAxBb,MAwBa,CAAA,MAAA,EAAA,MAAA,GAAA,SAAA,CAAA;EAAA,CAAA;;AAGN;AAMpB;AAyBA;AAaA;AAqCiB,KApGL,WAAA,GAoGK,QAAqB,GAAA,QAAA,GAAA,OAAA;;;;;AAkB/B,KAhHK,gBAAA,GAgHL,UAAA,GAAA,QAAA,GAAA,KAAA,GAAA,OAAA,GAAA,MAAA;;;AAAiC;AAOxC;;;;;AAyCwB,KAtJZ,cAAA,GAsJY,CAAA,GAAA,EArJjB,aAqJiB,EAAA,YAAA,EAAA,MAAA,EAAA,GAAA,MAAA,GAnJV,MAmJU,CAAA,MAAA,EAAA,OAAA,CAAA;;;AAmC4B;AA4kBpD;AAA4B,UA5vBX,oBAAA,CA4vBW;EAAA;EAAmC,MAAG,EAAA,MAAA;EAA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;;+BAaY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAipBf,YAAA,WAAsB,uBAA4B"}
package/dist/mod.js CHANGED
@@ -273,6 +273,17 @@ const elysiaRouteMethods = [
273
273
  "post",
274
274
  "put"
275
275
  ];
276
+ const elysiaRouteHookKeys = [
277
+ "afterHandle",
278
+ "afterResponse",
279
+ "beforeHandle",
280
+ "derive",
281
+ "error",
282
+ "mapResponse",
283
+ "parse",
284
+ "resolve",
285
+ "transform"
286
+ ];
276
287
  function getElysiaRouteEntries(plugin) {
277
288
  if (plugin == null || typeof plugin !== "object") return [];
278
289
  const routePlugin = plugin;
@@ -286,41 +297,83 @@ function getElysiaRouteEntries(plugin) {
286
297
  function wrapLocalRouteHandlers(plugin, buildAndStoreRequestContext, applyRequestContextToSet) {
287
298
  const wrappedHandlers = /* @__PURE__ */ new WeakSet();
288
299
  const wrappedHandlerCache = /* @__PURE__ */ new WeakMap();
289
- const wrapHandler = (handler) => {
290
- if (typeof handler !== "function") return handler;
291
- const routeHandler = handler;
292
- if (wrappedHandlers.has(routeHandler)) return handler;
293
- const cached = wrappedHandlerCache.get(routeHandler);
300
+ const getRouteContext = (value) => {
301
+ if (value == null || typeof value !== "object") return void 0;
302
+ const context = value;
303
+ if (!(context.request instanceof Request)) return void 0;
304
+ return value;
305
+ };
306
+ const wrapRequestCallback = (callback) => {
307
+ if (typeof callback !== "function") return callback;
308
+ const requestCallback = callback;
309
+ if (wrappedHandlers.has(requestCallback)) return callback;
310
+ const cached = wrappedHandlerCache.get(requestCallback);
294
311
  if (cached != null) return cached;
295
- const wrapped = async function(ctx) {
312
+ const wrapped = async function(...args) {
313
+ const ctx = getRouteContext(args[0]);
314
+ if (ctx == null) return await requestCallback.apply(this, args);
296
315
  const requestContext = await buildAndStoreRequestContext(ctx.request);
297
316
  ctx.store.startTime = requestContext?.startTime ?? performance.now();
298
317
  applyRequestContextToSet(ctx.set, requestContext);
299
- return await withContext(requestContext?.context ?? {}, () => routeHandler.call(this, ctx));
318
+ return await withContext(requestContext?.context ?? {}, () => requestCallback.apply(this, args));
300
319
  };
301
320
  wrappedHandlers.add(wrapped);
302
- wrappedHandlerCache.set(routeHandler, wrapped);
321
+ wrappedHandlerCache.set(requestCallback, wrapped);
303
322
  return wrapped;
304
323
  };
324
+ const wrapRouteHookValue = (value) => {
325
+ if (Array.isArray(value)) return value.map(wrapRouteHookValue);
326
+ if (typeof value === "function") return wrapRequestCallback(value);
327
+ if (value == null || typeof value !== "object") return value;
328
+ const hookContainer = value;
329
+ if (typeof hookContainer.fn !== "function") return value;
330
+ return {
331
+ ...hookContainer,
332
+ fn: wrapRequestCallback(hookContainer.fn)
333
+ };
334
+ };
335
+ const wrapRouteHooks = (hooks) => {
336
+ if (hooks == null || typeof hooks !== "object") return hooks;
337
+ const routeHooks = hooks;
338
+ let changed = false;
339
+ const wrappedHooks = { ...routeHooks };
340
+ for (const key of elysiaRouteHookKeys) {
341
+ const value = routeHooks[key];
342
+ const wrappedValue = wrapRouteHookValue(value);
343
+ if (wrappedValue === value) continue;
344
+ wrappedHooks[key] = wrappedValue;
345
+ changed = true;
346
+ }
347
+ return changed ? wrappedHooks : hooks;
348
+ };
305
349
  const wrapRouteEntries = (routePlugin) => {
306
350
  const restore = [];
307
351
  for (const route$1 of getElysiaRouteEntries(routePlugin)) {
308
352
  const handler = route$1.handler;
309
- const wrappedHandler = wrapHandler(handler);
310
- if (wrappedHandler === handler) continue;
311
- route$1.handler = wrappedHandler;
312
- restore.push(() => {
313
- route$1.handler = handler;
314
- });
353
+ const wrappedHandler = wrapRequestCallback(handler);
354
+ if (wrappedHandler !== handler) {
355
+ route$1.handler = wrappedHandler;
356
+ restore.push(() => {
357
+ route$1.handler = handler;
358
+ });
359
+ }
360
+ const hooks = route$1.hooks;
361
+ const wrappedHooks = wrapRouteHooks(hooks);
362
+ if (wrappedHooks !== hooks) {
363
+ route$1.hooks = wrappedHooks;
364
+ restore.push(() => {
365
+ route$1.hooks = hooks;
366
+ });
367
+ }
315
368
  }
316
369
  return restore;
317
370
  };
318
371
  for (const method of elysiaRouteMethods) {
319
372
  const register = plugin[method].bind(plugin);
320
- plugin[method] = (path, handler, hook) => register(path, wrapHandler(handler), hook);
373
+ plugin[method] = (path, handler, hook) => register(path, wrapRequestCallback(handler), wrapRouteHooks(hook));
321
374
  }
322
375
  const route = plugin.route.bind(plugin);
323
- plugin.route = (method, path, handler, hook) => route(method, path, wrapHandler(handler), hook);
376
+ plugin.route = (method, path, handler, hook) => route(method, path, wrapRequestCallback(handler), wrapRouteHooks(hook));
324
377
  const use = plugin.use.bind(plugin);
325
378
  plugin.use = (childPlugin, ...options) => {
326
379
  const restore = wrapRouteEntries(childPlugin);
package/dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":["options: boolean | RequestContextOptions | undefined","options: boolean | RequestIdOptions | undefined","value: string","request: Request","options: RequestIdOptions","responseHeader","resolvedRequestId:\n | { readonly property: string; readonly value: string }\n | undefined","include: readonly RequestContextField[]","context: Record<string, unknown>","options: RequestContextOptions","set: ElysiaContext[\"set\"] | undefined","headers: Record<string, string | undefined>","ctx: ElysiaContext","responseTime: number","result: string | Record<string, unknown>","predefinedFormats: Record<PredefinedFormat, FormatFunction>","category: string | readonly string[]","errorCodeToStatus: Record<string, number>","code: string | number","error: unknown","setStatus: number","elysiaRouteMethods: readonly ElysiaRouteMethod[]","plugin: unknown","plugin: ElysiaRoutePlugin","buildAndStoreRequestContext: (\n request: Request,\n ) => Promise<ElysiaRequestContextState | undefined>","applyRequestContextToSet: (\n set: ElysiaContext[\"set\"],\n requestContext: ElysiaRequestContextState | undefined,\n ) => void","handler: unknown","ctx: ElysiaRouteContext","routePlugin: unknown","restore: (() => void)[]","route","path: string","hook?: unknown","method: string","childPlugin: unknown","options: ElysiaLogTapeOptions","formatFn: FormatFunction","set: ElysiaContext[\"set\"]","requestContext: ElysiaRequestContextState | undefined","plugin: Elysia<any, any, any, any, any, any, any>"],"sources":["../src/mod.ts"],"sourcesContent":["import { Elysia } from \"elysia\";\nimport { getLogger, type LogLevel, withContext } from \"@logtape/logtape\";\n\nexport type { LogLevel } from \"@logtape/logtape\";\n\n/**\n * Minimal Elysia Context interface for compatibility.\n * @since 2.0.0\n */\nexport interface ElysiaContext {\n request: Request;\n path: string;\n set: {\n status: number;\n headers: Record<string, string | undefined>;\n };\n}\n\n/**\n * Plugin scope options for controlling hook propagation.\n * @since 2.0.0\n */\nexport type PluginScope = \"global\" | \"scoped\" | \"local\";\n\n/**\n * Predefined log format names compatible with Morgan.\n * @since 2.0.0\n */\nexport type PredefinedFormat = \"combined\" | \"common\" | \"dev\" | \"short\" | \"tiny\";\n\n/**\n * Custom format function for request logging.\n *\n * @param ctx The Elysia context object.\n * @param responseTime The response time in milliseconds.\n * @returns A string message or an object with structured properties.\n * @since 2.0.0\n */\nexport type FormatFunction = (\n ctx: ElysiaContext,\n responseTime: number,\n) => string | Record<string, unknown>;\n\n/**\n * Structured log properties for HTTP requests.\n * @since 2.0.0\n */\nexport interface RequestLogProperties {\n /** HTTP request method */\n method: string;\n /** Request URL */\n url: string;\n /** Request path */\n path: string;\n /** HTTP response status code */\n status: number;\n /** Response time in milliseconds */\n responseTime: number;\n /** Response content-length header value */\n contentLength: string | undefined;\n /** Remote client address (from X-Forwarded-For header) */\n remoteAddr: string | undefined;\n /** User-Agent header value */\n userAgent: string | undefined;\n /** Referrer header value */\n referrer: string | undefined;\n}\n\n/**\n * Request fields that can be added to the implicit request context.\n * @since 2.2.0\n */\nexport type RequestContextField =\n | \"requestId\"\n | \"method\"\n | \"url\"\n | \"path\"\n | \"userAgent\"\n | \"remoteAddr\"\n | \"referrer\";\n\n/**\n * Options for extracting, generating, and propagating a request ID.\n * @since 2.2.0\n */\nexport interface RequestIdOptions {\n /**\n * The property name used in implicit context and request log records.\n * @default \"requestId\"\n */\n readonly property?: string;\n\n /**\n * Incoming request headers to inspect in order.\n * @default [\"x-request-id\"]\n */\n readonly headerNames?: readonly string[];\n\n /**\n * Response header that receives the resolved request ID.\n * Set to `false` to disable response header propagation.\n * @default \"x-request-id\"\n */\n readonly responseHeader?: string | false;\n\n /**\n * Generates a request ID when no incoming header is present.\n * @default crypto.randomUUID()\n */\n readonly generate?: () => string;\n\n /**\n * Normalizes an incoming request ID. Return `null` to reject the value and\n * keep looking for another header or generate a new ID.\n */\n readonly normalize?: (value: string) => string | null;\n}\n\n/**\n * Options for request-scoped implicit context.\n * @since 2.2.0\n */\nexport interface RequestContextOptions {\n /**\n * Enables request ID extraction, generation, and response propagation.\n * @default true\n */\n readonly requestId?: boolean | RequestIdOptions;\n\n /**\n * Fields to add to the implicit context.\n * @default [\"requestId\"]\n */\n readonly include?: readonly RequestContextField[];\n\n /**\n * Adds application-specific fields to the implicit request context.\n */\n readonly enrich?: (\n ctx: ElysiaContext,\n ) => Record<string, unknown> | Promise<Record<string, unknown>>;\n}\n\n/**\n * Options for configuring the Elysia LogTape middleware.\n * @since 2.0.0\n */\nexport interface ElysiaLogTapeOptions {\n /**\n * The LogTape category to use for logging.\n * @default [\"elysia\"]\n */\n readonly category?: string | readonly string[];\n\n /**\n * The log level to use for request logging.\n * @default \"info\"\n */\n readonly level?: LogLevel;\n\n /**\n * The format for log output.\n * Can be a predefined format name or a custom format function.\n *\n * Predefined formats:\n * - `\"combined\"` - Apache Combined Log Format (structured, default)\n * - `\"common\"` - Apache Common Log Format (structured, no referrer/userAgent)\n * - `\"dev\"` - Concise colored output for development (string)\n * - `\"short\"` - Shorter than common (string)\n * - `\"tiny\"` - Minimal output (string)\n *\n * @default \"combined\"\n */\n readonly format?: PredefinedFormat | FormatFunction;\n\n /**\n * Function to determine whether logging should be skipped.\n * Return `true` to skip logging for a request.\n *\n * @example Skip logging for health check endpoint\n * ```typescript\n * app.use(elysiaLogger({\n * skip: (ctx) => ctx.path === \"/health\",\n * }));\n * ```\n *\n * @default () => false\n */\n readonly skip?: (ctx: ElysiaContext) => boolean;\n\n /**\n * If `true`, logs are written immediately when the request is received.\n * If `false` (default), logs are written after the response is sent.\n *\n * Note: When `logRequest` is `true`, response-related properties\n * (status, responseTime, contentLength) will not be available.\n *\n * @default false\n */\n readonly logRequest?: boolean;\n\n /**\n * The plugin scope for controlling how lifecycle hooks are propagated.\n *\n * - `\"global\"` - Hooks apply to all routes in the application\n * - `\"scoped\"` - Hooks apply to the parent instance where the plugin is used\n * - `\"local\"` - Hooks only apply within the plugin itself\n *\n * @default \"global\"\n */\n readonly scope?: PluginScope;\n\n /**\n * Enables request-scoped implicit context and request ID correlation.\n *\n * When set to `true`, the plugin reads the `x-request-id` header, generates\n * one when it is absent, writes it to the `x-request-id` response header,\n * and adds `requestId` to all LogTape records emitted while handling the\n * request.\n *\n * @default false\n * @since 2.2.0\n */\n readonly context?: boolean | RequestContextOptions;\n}\n\nconst defaultRequestIdHeader = \"x-request-id\";\n\n/**\n * Per-request context state stored outside Elysia's shared store.\n */\ninterface ElysiaRequestContextState {\n readonly context: Record<string, unknown>;\n readonly startTime?: number;\n readonly responseHeader?: {\n readonly name: string;\n readonly value: string;\n };\n readonly set?: ElysiaContext[\"set\"];\n}\n\n/**\n * Normalize request context options.\n */\nfunction normalizeRequestContextOptions(\n options: boolean | RequestContextOptions | undefined,\n): RequestContextOptions | undefined {\n if (options === true) return {};\n if (options === false || options == null) return undefined;\n return options;\n}\n\n/**\n * Normalize request ID options.\n */\nfunction normalizeRequestIdOptions(\n options: boolean | RequestIdOptions | undefined,\n): RequestIdOptions | undefined {\n if (options === false) return undefined;\n if (options === true || options == null) return {};\n return options;\n}\n\n/**\n * Generate a request ID with Web Crypto when possible.\n */\nfunction generateRequestId(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\n/**\n * Normalize an incoming request ID.\n */\nfunction defaultNormalizeRequestId(value: string): string | null {\n const trimmed = value.trim();\n return trimmed === \"\" ? null : trimmed;\n}\n\n/**\n * Resolve a request path from a request URL.\n */\nfunction getPath(request: Request): string {\n return new URL(request.url, \"http://localhost\").pathname;\n}\n\n/**\n * Resolve the request ID for a request.\n */\nfunction resolveRequestId(\n request: Request,\n options: RequestIdOptions,\n): {\n readonly property: string;\n readonly value: string;\n readonly responseHeader?: string;\n} {\n const property = options.property ?? \"requestId\";\n const normalize = options.normalize ?? defaultNormalizeRequestId;\n const headerNames = options.headerNames ?? [defaultRequestIdHeader];\n for (const headerName of headerNames) {\n const headerValue = request.headers.get(headerName);\n if (headerValue == null) continue;\n const normalized = normalize(headerValue);\n if (normalized != null) {\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n return {\n property,\n value: normalized,\n responseHeader: responseHeader === false ? undefined : responseHeader,\n };\n }\n }\n const generated = (options.generate ?? generateRequestId)();\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n return {\n property,\n value: generated,\n responseHeader: responseHeader === false ? undefined : responseHeader,\n };\n}\n\n/**\n * Get referrer from request headers.\n */\nfunction getReferrer(request: Request): string | undefined {\n return request.headers.get(\"referrer\") ??\n request.headers.get(\"referer\") ??\n undefined;\n}\n\n/**\n * Get user agent from request headers.\n */\nfunction getUserAgent(request: Request): string | undefined {\n return request.headers.get(\"user-agent\") ?? undefined;\n}\n\n/**\n * Get remote address from X-Forwarded-For header.\n */\nfunction getRemoteAddr(request: Request): string | undefined {\n const forwarded = request.headers.get(\"x-forwarded-for\");\n if (forwarded) {\n // X-Forwarded-For can contain multiple IPs, take the first one\n const firstIp = forwarded.split(\",\")[0].trim();\n return firstIp || undefined;\n }\n return undefined;\n}\n\n/**\n * Build request context fields from a request.\n */\nfunction buildIncludedContext(\n request: Request,\n resolvedRequestId:\n | { readonly property: string; readonly value: string }\n | undefined,\n include: readonly RequestContextField[],\n): Record<string, unknown> {\n const context: Record<string, unknown> = {};\n for (const field of include) {\n switch (field) {\n case \"requestId\":\n if (resolvedRequestId != null) {\n context[resolvedRequestId.property] = resolvedRequestId.value;\n }\n break;\n case \"method\":\n context.method = request.method;\n break;\n case \"url\":\n context.url = request.url;\n break;\n case \"path\":\n context.path = getPath(request);\n break;\n case \"userAgent\":\n context.userAgent = getUserAgent(request);\n break;\n case \"remoteAddr\":\n context.remoteAddr = getRemoteAddr(request);\n break;\n case \"referrer\":\n context.referrer = getReferrer(request);\n break;\n }\n }\n return context;\n}\n\n/**\n * Build the implicit context for a request.\n */\nasync function buildRequestContext(\n request: Request,\n options: RequestContextOptions,\n): Promise<ElysiaRequestContextState> {\n const requestIdOptions = normalizeRequestIdOptions(options.requestId);\n const resolvedRequestId = requestIdOptions == null\n ? undefined\n : resolveRequestId(request, requestIdOptions);\n const include = options.include ??\n (resolvedRequestId == null ? [] : [\"requestId\"] as const);\n const context = buildIncludedContext(request, resolvedRequestId, include);\n let set: ElysiaContext[\"set\"] | undefined;\n if (options.enrich != null) {\n set = { status: 200, headers: {} };\n Object.assign(\n context,\n await options.enrich({\n request,\n path: getPath(request),\n set,\n }),\n );\n }\n const responseHeader = resolvedRequestId?.responseHeader == null\n ? undefined\n : {\n name: resolvedRequestId.responseHeader,\n value: resolvedRequestId.value,\n };\n return { context, responseHeader, set };\n}\n\n/**\n * Get content length from response headers.\n */\nfunction getContentLength(\n headers: Record<string, string | undefined>,\n): string | undefined {\n const contentLength = headers[\"content-length\"];\n if (contentLength === undefined || contentLength === null) return undefined;\n return contentLength;\n}\n\n/**\n * Build structured log properties from context.\n */\nfunction buildProperties(\n ctx: ElysiaContext,\n responseTime: number,\n): RequestLogProperties {\n return {\n method: ctx.request.method,\n url: ctx.request.url,\n path: ctx.path,\n status: ctx.set.status,\n responseTime,\n contentLength: getContentLength(ctx.set.headers),\n remoteAddr: getRemoteAddr(ctx.request),\n userAgent: getUserAgent(ctx.request),\n referrer: getReferrer(ctx.request),\n };\n}\n\n/**\n * Add request context fields to a request log result.\n */\nfunction withRequestLogContext(\n result: string | Record<string, unknown>,\n context: Record<string, unknown>,\n): string | Record<string, unknown> {\n if (typeof result === \"string\") return result;\n return { ...result, ...context };\n}\n\n/**\n * Combined format (Apache Combined Log Format).\n * Returns all structured properties.\n */\nfunction formatCombined(\n ctx: ElysiaContext,\n responseTime: number,\n): Record<string, unknown> {\n return { ...buildProperties(ctx, responseTime) };\n}\n\n/**\n * Common format (Apache Common Log Format).\n * Like combined but without referrer and userAgent.\n */\nfunction formatCommon(\n ctx: ElysiaContext,\n responseTime: number,\n): Record<string, unknown> {\n const props = buildProperties(ctx, responseTime);\n const { referrer: _referrer, userAgent: _userAgent, ...rest } = props;\n return rest;\n}\n\n/**\n * Dev format (colored output for development).\n * :method :path :status :response-time ms - :res[content-length]\n */\nfunction formatDev(ctx: ElysiaContext, responseTime: number): string {\n const contentLength = getContentLength(ctx.set.headers) ?? \"-\";\n return `${ctx.request.method} ${ctx.path} ${ctx.set.status} ${\n responseTime.toFixed(3)\n } ms - ${contentLength}`;\n}\n\n/**\n * Short format.\n * :remote-addr :method :url :status :res[content-length] - :response-time ms\n */\nfunction formatShort(ctx: ElysiaContext, responseTime: number): string {\n const remoteAddr = getRemoteAddr(ctx.request) ?? \"-\";\n const contentLength = getContentLength(ctx.set.headers) ?? \"-\";\n return `${remoteAddr} ${ctx.request.method} ${ctx.request.url} ${ctx.set.status} ${contentLength} - ${\n responseTime.toFixed(3)\n } ms`;\n}\n\n/**\n * Tiny format (minimal output).\n * :method :path :status :res[content-length] - :response-time ms\n */\nfunction formatTiny(ctx: ElysiaContext, responseTime: number): string {\n const contentLength = getContentLength(ctx.set.headers) ?? \"-\";\n return `${ctx.request.method} ${ctx.path} ${ctx.set.status} ${contentLength} - ${\n responseTime.toFixed(3)\n } ms`;\n}\n\n/**\n * Map of predefined format functions.\n */\nconst predefinedFormats: Record<PredefinedFormat, FormatFunction> = {\n combined: formatCombined,\n common: formatCommon,\n dev: formatDev,\n short: formatShort,\n tiny: formatTiny,\n};\n\n/**\n * Normalize category to array format.\n */\nfunction normalizeCategory(\n category: string | readonly string[],\n): readonly string[] {\n return typeof category === \"string\" ? [category] : category;\n}\n\n/**\n * Mapping of Elysia error codes to HTTP status codes.\n */\nconst errorCodeToStatus: Record<string, number> = {\n NOT_FOUND: 404,\n VALIDATION: 422,\n PARSE: 400,\n INTERNAL_SERVER_ERROR: 500,\n INVALID_COOKIE_SIGNATURE: 400,\n UNKNOWN: 500,\n};\n\n/**\n * Get the HTTP status code from an error context.\n * Checks error.status first, then falls back to error code mapping.\n */\nfunction getErrorStatus(\n code: string | number,\n error: unknown,\n setStatus: number,\n): number {\n // If code is already a number, use it as status\n if (typeof code === \"number\") {\n return code;\n }\n // Check if error has a status property (Elysia custom errors)\n if (\n error != null &&\n typeof error === \"object\" &&\n \"status\" in error &&\n typeof error.status === \"number\"\n ) {\n return error.status;\n }\n // Fall back to error code mapping\n if (code in errorCodeToStatus) {\n return errorCodeToStatus[code];\n }\n // Use set.status as last resort\n return setStatus;\n}\n\n/**\n * Internal store type for timing.\n */\ninterface LoggerStore {\n startTime: number;\n}\n\ntype ElysiaRouteContext = ElysiaContext & {\n readonly store: LoggerStore;\n};\n\ntype ElysiaRouteHandler = (\n this: unknown,\n context: ElysiaRouteContext,\n) => unknown;\n\ntype ElysiaRouteRegistrar = (\n path: string,\n handler: unknown,\n hook?: unknown,\n) => unknown;\n\ntype ElysiaUseRegistrar = (\n plugin: unknown,\n ...options: unknown[]\n) => unknown;\n\ntype ElysiaRouteMethod =\n | \"all\"\n | \"connect\"\n | \"delete\"\n | \"get\"\n | \"head\"\n | \"options\"\n | \"patch\"\n | \"post\"\n | \"put\";\n\nconst elysiaRouteMethods: readonly ElysiaRouteMethod[] = [\n \"all\",\n \"connect\",\n \"delete\",\n \"get\",\n \"head\",\n \"options\",\n \"patch\",\n \"post\",\n \"put\",\n];\n\ntype ElysiaRoutePlugin = Record<ElysiaRouteMethod, ElysiaRouteRegistrar> & {\n readonly router?: {\n readonly history?: Record<string, ElysiaRouteEntry> | ElysiaRouteEntry[];\n };\n route: (\n method: string,\n path: string,\n handler: unknown,\n hook?: unknown,\n ) => unknown;\n use: ElysiaUseRegistrar;\n};\n\ninterface ElysiaRouteEntry {\n handler?: unknown;\n}\n\nfunction getElysiaRouteEntries(plugin: unknown): ElysiaRouteEntry[] {\n if (plugin == null || typeof plugin !== \"object\") return [];\n const routePlugin = plugin as {\n readonly default?: unknown;\n readonly router?: {\n readonly history?: Record<string, ElysiaRouteEntry> | ElysiaRouteEntry[];\n };\n };\n const history = routePlugin.router?.history;\n const entries = Array.isArray(history)\n ? history\n : history == null\n ? []\n : Object.values(history);\n return entries.concat(getElysiaRouteEntries(routePlugin.default));\n}\n\n/**\n * Wrap routes registered on a local plugin with implicit LogTape context.\n */\nfunction wrapLocalRouteHandlers(\n plugin: ElysiaRoutePlugin,\n buildAndStoreRequestContext: (\n request: Request,\n ) => Promise<ElysiaRequestContextState | undefined>,\n applyRequestContextToSet: (\n set: ElysiaContext[\"set\"],\n requestContext: ElysiaRequestContextState | undefined,\n ) => void,\n): void {\n const wrappedHandlers = new WeakSet<ElysiaRouteHandler>();\n const wrappedHandlerCache = new WeakMap<\n ElysiaRouteHandler,\n ElysiaRouteHandler\n >();\n const wrapHandler = (handler: unknown): unknown => {\n if (typeof handler !== \"function\") return handler;\n const routeHandler = handler as ElysiaRouteHandler;\n if (wrappedHandlers.has(routeHandler)) return handler;\n const cached = wrappedHandlerCache.get(routeHandler);\n if (cached != null) return cached;\n const wrapped = async function (\n this: unknown,\n ctx: ElysiaRouteContext,\n ): Promise<unknown> {\n const requestContext = await buildAndStoreRequestContext(ctx.request);\n ctx.store.startTime = requestContext?.startTime ??\n performance.now();\n applyRequestContextToSet(ctx.set, requestContext);\n return await withContext(\n requestContext?.context ?? {},\n () => routeHandler.call(this, ctx),\n );\n };\n wrappedHandlers.add(wrapped);\n wrappedHandlerCache.set(routeHandler, wrapped);\n return wrapped;\n };\n\n const wrapRouteEntries = (routePlugin: unknown): (() => void)[] => {\n const restore: (() => void)[] = [];\n for (const route of getElysiaRouteEntries(routePlugin)) {\n const handler = route.handler;\n const wrappedHandler = wrapHandler(handler);\n if (wrappedHandler === handler) continue;\n route.handler = wrappedHandler;\n restore.push(() => {\n route.handler = handler;\n });\n }\n return restore;\n };\n\n for (const method of elysiaRouteMethods) {\n const register = plugin[method].bind(plugin);\n plugin[method] = ((path: string, handler: unknown, hook?: unknown) =>\n register(path, wrapHandler(handler), hook)) as ElysiaRouteRegistrar;\n }\n\n const route = plugin.route.bind(plugin);\n plugin.route = ((\n method: string,\n path: string,\n handler: unknown,\n hook?: unknown,\n ) => route(method, path, wrapHandler(handler), hook)) as ElysiaRoutePlugin[\n \"route\"\n ];\n\n const use = plugin.use.bind(plugin);\n plugin.use = ((childPlugin: unknown, ...options: unknown[]) => {\n const restore = wrapRouteEntries(childPlugin);\n try {\n return use(childPlugin, ...options);\n } finally {\n for (const restoreRouteHandler of restore) restoreRouteHandler();\n }\n }) as ElysiaUseRegistrar;\n}\n\n/**\n * Creates Elysia plugin for HTTP request logging using LogTape.\n *\n * This plugin provides Morgan-compatible request logging with LogTape\n * as the backend, supporting structured logging and customizable formats.\n *\n * @example Basic usage\n * ```typescript\n * import { Elysia } from \"elysia\";\n * import { configure, getConsoleSink } from \"@logtape/logtape\";\n * import { elysiaLogger } from \"@logtape/elysia\";\n *\n * await configure({\n * sinks: { console: getConsoleSink() },\n * loggers: [\n * { category: [\"elysia\"], sinks: [\"console\"], lowestLevel: \"info\" }\n * ],\n * });\n *\n * const app = new Elysia()\n * .use(elysiaLogger())\n * .get(\"/\", () => ({ hello: \"world\" }))\n * .listen(3000);\n * ```\n *\n * @example With custom options\n * ```typescript\n * app.use(elysiaLogger({\n * category: [\"myapp\", \"http\"],\n * level: \"debug\",\n * format: \"dev\",\n * skip: (ctx) => ctx.path === \"/health\",\n * scope: \"scoped\",\n * }));\n * ```\n *\n * @example With custom format function\n * ```typescript\n * app.use(elysiaLogger({\n * format: (ctx, responseTime) => ({\n * method: ctx.request.method,\n * path: ctx.path,\n * status: ctx.set.status,\n * duration: responseTime,\n * }),\n * }));\n * ```\n *\n * @param options Configuration options for the plugin.\n * @returns Elysia plugin instance.\n * @since 2.0.0\n */\n// deno-lint-ignore no-explicit-any\nexport function elysiaLogger(options: ElysiaLogTapeOptions = {}): Elysia<any> {\n const category = normalizeCategory(options.category ?? [\"elysia\"]);\n const logger = getLogger(category);\n const level = options.level ?? \"info\";\n const formatOption = options.format ?? \"combined\";\n const skip = options.skip ?? (() => false);\n const logRequest = options.logRequest ?? false;\n const scope = options.scope ?? \"global\";\n const contextOptions = normalizeRequestContextOptions(options.context);\n const requestContextStates = new WeakMap<\n Request,\n ElysiaRequestContextState\n >();\n const shouldWrapContext = contextOptions != null;\n const shouldWrapAllRoutes = contextOptions != null && scope !== \"local\";\n\n // Resolve format function\n const formatFn: FormatFunction = typeof formatOption === \"string\"\n ? predefinedFormats[formatOption]\n : formatOption;\n\n const logMethod = logger[level].bind(logger);\n const errorLogMethod = logger.error.bind(logger);\n\n const buildAndStoreRequestContext = async (\n request: Request,\n ): Promise<ElysiaRequestContextState | undefined> => {\n if (contextOptions == null) return undefined;\n const existingContext = requestContextStates.get(request);\n if (existingContext != null) return existingContext;\n const startTime = performance.now();\n const requestContext = {\n ...await buildRequestContext(request, contextOptions),\n startTime,\n };\n requestContextStates.set(request, requestContext);\n return requestContext;\n };\n\n const applyRequestContextToSet = (\n set: ElysiaContext[\"set\"],\n requestContext: ElysiaRequestContextState | undefined,\n ): void => {\n if (requestContext?.responseHeader != null) {\n set.headers[requestContext.responseHeader.name] =\n requestContext.responseHeader.value;\n }\n if (requestContext?.set != null) {\n if (requestContext.set.status !== 200) {\n set.status = requestContext.set.status;\n }\n Object.assign(set.headers, requestContext.set.headers);\n }\n };\n\n // deno-lint-ignore no-explicit-any\n let plugin: Elysia<any, any, any, any, any, any, any> = new Elysia({\n name: \"@logtape/elysia\",\n seed: options,\n });\n\n if (shouldWrapContext && scope === \"local\") {\n wrapLocalRouteHandlers(\n plugin as unknown as ElysiaRoutePlugin,\n buildAndStoreRequestContext,\n applyRequestContextToSet,\n );\n } else if (shouldWrapContext) {\n // Elysia lifecycle hooks cannot wrap downstream handlers, so use wrap()\n // to keep AsyncLocalStorage active for the whole route execution.\n plugin = plugin.wrap((handle) => {\n return async (request: Request) => {\n const requestContext = await buildAndStoreRequestContext(request);\n return await withContext(\n requestContext?.context ?? {},\n () => handle(request),\n );\n };\n });\n }\n\n plugin = plugin\n .state(\"startTime\", 0)\n .onRequest(async ({ request, set, store }) => {\n let requestContext = requestContextStates.get(request);\n if (requestContext == null && shouldWrapAllRoutes) {\n requestContext = await buildAndStoreRequestContext(request);\n }\n (store as LoggerStore).startTime = requestContext?.startTime ??\n performance.now();\n applyRequestContextToSet(set, requestContext);\n });\n\n if (scope === \"local\" && (contextOptions != null || logRequest)) {\n plugin = plugin.onBeforeHandle(async (ctx) => {\n const requestContext = await buildAndStoreRequestContext(ctx.request);\n (ctx.store as LoggerStore).startTime = requestContext?.startTime ??\n performance.now();\n applyRequestContextToSet(ctx.set, requestContext);\n if (logRequest && !skip(ctx as unknown as ElysiaContext)) {\n const context = requestContext?.context ?? {};\n const result = withRequestLogContext(\n formatFn(ctx as unknown as ElysiaContext, 0),\n context,\n );\n if (typeof result === \"string\") {\n logMethod(result, context);\n } else {\n logMethod(\"{method} {url}\", result);\n }\n }\n });\n }\n\n if (logRequest) {\n // Log immediately when request arrives\n if (scope !== \"local\") {\n plugin = plugin.onRequest((ctx) => {\n if (!skip(ctx as unknown as ElysiaContext)) {\n const requestContext =\n requestContextStates.get(ctx.request)?.context ??\n {};\n const result = withRequestLogContext(\n formatFn(ctx as unknown as ElysiaContext, 0),\n requestContext,\n );\n if (typeof result === \"string\") {\n logMethod(result, requestContext);\n } else {\n logMethod(\"{method} {url}\", result);\n }\n }\n });\n }\n } else {\n // Log after handler completes\n plugin = plugin.onAfterHandle((ctx) => {\n if (skip(ctx as unknown as ElysiaContext)) return;\n\n const store = ctx.store as LoggerStore;\n const responseTime = performance.now() - store.startTime;\n const requestContext = requestContextStates.get(ctx.request)?.context ??\n {};\n const result = withRequestLogContext(\n formatFn(ctx as unknown as ElysiaContext, responseTime),\n requestContext,\n );\n\n if (typeof result === \"string\") {\n logMethod(result, requestContext);\n } else {\n logMethod(\"{method} {url} {status} - {responseTime} ms\", result);\n }\n });\n }\n\n // Add error logging\n plugin = plugin.onError((ctx) => {\n const store = ctx.store as LoggerStore;\n const responseTime = performance.now() - store.startTime;\n const elysiaCtx = ctx as unknown as ElysiaContext;\n\n if (skip(elysiaCtx)) return;\n\n const props = buildProperties(elysiaCtx, responseTime);\n const requestContext = requestContextStates.get(ctx.request)?.context ?? {};\n // Get the correct HTTP status code from error context\n const status = getErrorStatus(ctx.code, ctx.error, elysiaCtx.set.status);\n // Extract error message safely\n const error = ctx.error as { message?: string } | undefined;\n const errorMessage = error?.message ?? \"Unknown error\";\n errorLogMethod(\n \"Error: {method} {url} {status} - {responseTime} ms - {errorMessage}\",\n {\n ...props,\n ...requestContext,\n status,\n errorMessage,\n errorCode: ctx.code,\n },\n );\n });\n\n // Apply scope\n if (scope === \"global\") {\n // deno-lint-ignore no-explicit-any\n return plugin.as(\"global\") as unknown as Elysia<any>;\n } else if (scope === \"scoped\") {\n // deno-lint-ignore no-explicit-any\n return plugin.as(\"scoped\") as unknown as Elysia<any>;\n }\n\n // deno-lint-ignore no-explicit-any\n return plugin as unknown as Elysia<any>;\n}\n"],"mappings":";;;;AAkOA,MAAM,yBAAyB;;;;AAkB/B,SAAS,+BACPA,SACmC;AACnC,KAAI,YAAY,KAAM,QAAO,CAAE;AAC/B,KAAI,YAAY,SAAS,WAAW,KAAM;AAC1C,QAAO;AACR;;;;AAKD,SAAS,0BACPC,SAC8B;AAC9B,KAAI,YAAY,MAAO;AACvB,KAAI,YAAY,QAAQ,WAAW,KAAM,QAAO,CAAE;AAClD,QAAO;AACR;;;;AAKD,SAAS,oBAA4B;AACnC,YAAW,WAAW,QAAQ,eAAe,WAC3C,QAAO,WAAW,OAAO,YAA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,EAAC;CACH,MAGD,UAAS,OAAO,cAAc,CAAC,QAAQ;AACrC,MAAI,KAAK,IAAgC,CAAE;EAE3C,MAAM,QAAQ,IAAI;EAClB,MAAM,eAAe,YAAY,KAAK,GAAG,MAAM;EAC/C,MAAM,iBAAiB,qBAAqB,IAAI,IAAI,QAAQ,EAAE,WAC5D,CAAE;EACJ,MAAM,SAAS,sBACb,SAAS,KAAiC,aAAa,EACvD,eACD;AAED,aAAW,WAAW,SACpB,WAAU,QAAQ,eAAe;MAEjC,WAAU,+CAA+C,OAAO;CAEnE,EAAC;AAIJ,UAAS,OAAO,QAAQ,CAAC,QAAQ;EAC/B,MAAM,QAAQ,IAAI;EAClB,MAAM,eAAe,YAAY,KAAK,GAAG,MAAM;EAC/C,MAAM,YAAY;AAElB,MAAI,KAAK,UAAU,CAAE;EAErB,MAAM,QAAQ,gBAAgB,WAAW,aAAa;EACtD,MAAM,iBAAiB,qBAAqB,IAAI,IAAI,QAAQ,EAAE,WAAW,CAAE;EAE3E,MAAM,SAAS,eAAe,IAAI,MAAM,IAAI,OAAO,UAAU,IAAI,OAAO;EAExE,MAAM,QAAQ,IAAI;EAClB,MAAM,eAAe,OAAO,WAAW;AACvC,iBACE,uEACA;GACE,GAAG;GACH,GAAG;GACH;GACA;GACA,WAAW,IAAI;EAChB,EACF;CACF,EAAC;AAGF,KAAI,UAAU,SAEZ,QAAO,OAAO,GAAG,SAAS;UACjB,UAAU,SAEnB,QAAO,OAAO,GAAG,SAAS;AAI5B,QAAO;AACR"}
1
+ {"version":3,"file":"mod.js","names":["options: boolean | RequestContextOptions | undefined","options: boolean | RequestIdOptions | undefined","value: string","request: Request","options: RequestIdOptions","responseHeader","resolvedRequestId:\n | { readonly property: string; readonly value: string }\n | undefined","include: readonly RequestContextField[]","context: Record<string, unknown>","options: RequestContextOptions","set: ElysiaContext[\"set\"] | undefined","headers: Record<string, string | undefined>","ctx: ElysiaContext","responseTime: number","result: string | Record<string, unknown>","predefinedFormats: Record<PredefinedFormat, FormatFunction>","category: string | readonly string[]","errorCodeToStatus: Record<string, number>","code: string | number","error: unknown","setStatus: number","elysiaRouteMethods: readonly ElysiaRouteMethod[]","plugin: unknown","plugin: ElysiaRoutePlugin","buildAndStoreRequestContext: (\n request: Request,\n ) => Promise<ElysiaRequestContextState | undefined>","applyRequestContextToSet: (\n set: ElysiaContext[\"set\"],\n requestContext: ElysiaRequestContextState | undefined,\n ) => void","value: unknown","callback: unknown","hooks: unknown","routePlugin: unknown","restore: (() => void)[]","route","path: string","handler: unknown","hook?: unknown","method: string","childPlugin: unknown","options: ElysiaLogTapeOptions","formatFn: FormatFunction","set: ElysiaContext[\"set\"]","requestContext: ElysiaRequestContextState | undefined","plugin: Elysia<any, any, any, any, any, any, any>"],"sources":["../src/mod.ts"],"sourcesContent":["import { Elysia } from \"elysia\";\nimport { getLogger, type LogLevel, withContext } from \"@logtape/logtape\";\n\nexport type { LogLevel } from \"@logtape/logtape\";\n\n/**\n * Minimal Elysia Context interface for compatibility.\n * @since 2.0.0\n */\nexport interface ElysiaContext {\n request: Request;\n path: string;\n set: {\n status: number;\n headers: Record<string, string | undefined>;\n };\n}\n\n/**\n * Plugin scope options for controlling hook propagation.\n * @since 2.0.0\n */\nexport type PluginScope = \"global\" | \"scoped\" | \"local\";\n\n/**\n * Predefined log format names compatible with Morgan.\n * @since 2.0.0\n */\nexport type PredefinedFormat = \"combined\" | \"common\" | \"dev\" | \"short\" | \"tiny\";\n\n/**\n * Custom format function for request logging.\n *\n * @param ctx The Elysia context object.\n * @param responseTime The response time in milliseconds.\n * @returns A string message or an object with structured properties.\n * @since 2.0.0\n */\nexport type FormatFunction = (\n ctx: ElysiaContext,\n responseTime: number,\n) => string | Record<string, unknown>;\n\n/**\n * Structured log properties for HTTP requests.\n * @since 2.0.0\n */\nexport interface RequestLogProperties {\n /** HTTP request method */\n method: string;\n /** Request URL */\n url: string;\n /** Request path */\n path: string;\n /** HTTP response status code */\n status: number;\n /** Response time in milliseconds */\n responseTime: number;\n /** Response content-length header value */\n contentLength: string | undefined;\n /** Remote client address (from X-Forwarded-For header) */\n remoteAddr: string | undefined;\n /** User-Agent header value */\n userAgent: string | undefined;\n /** Referrer header value */\n referrer: string | undefined;\n}\n\n/**\n * Request fields that can be added to the implicit request context.\n * @since 2.2.0\n */\nexport type RequestContextField =\n | \"requestId\"\n | \"method\"\n | \"url\"\n | \"path\"\n | \"userAgent\"\n | \"remoteAddr\"\n | \"referrer\";\n\n/**\n * Options for extracting, generating, and propagating a request ID.\n * @since 2.2.0\n */\nexport interface RequestIdOptions {\n /**\n * The property name used in implicit context and request log records.\n * @default \"requestId\"\n */\n readonly property?: string;\n\n /**\n * Incoming request headers to inspect in order.\n * @default [\"x-request-id\"]\n */\n readonly headerNames?: readonly string[];\n\n /**\n * Response header that receives the resolved request ID.\n * Set to `false` to disable response header propagation.\n * @default \"x-request-id\"\n */\n readonly responseHeader?: string | false;\n\n /**\n * Generates a request ID when no incoming header is present.\n * @default crypto.randomUUID()\n */\n readonly generate?: () => string;\n\n /**\n * Normalizes an incoming request ID. Return `null` to reject the value and\n * keep looking for another header or generate a new ID.\n */\n readonly normalize?: (value: string) => string | null;\n}\n\n/**\n * Options for request-scoped implicit context.\n * @since 2.2.0\n */\nexport interface RequestContextOptions {\n /**\n * Enables request ID extraction, generation, and response propagation.\n * @default true\n */\n readonly requestId?: boolean | RequestIdOptions;\n\n /**\n * Fields to add to the implicit context.\n * @default [\"requestId\"]\n */\n readonly include?: readonly RequestContextField[];\n\n /**\n * Adds application-specific fields to the implicit request context.\n */\n readonly enrich?: (\n ctx: ElysiaContext,\n ) => Record<string, unknown> | Promise<Record<string, unknown>>;\n}\n\n/**\n * Options for configuring the Elysia LogTape middleware.\n * @since 2.0.0\n */\nexport interface ElysiaLogTapeOptions {\n /**\n * The LogTape category to use for logging.\n * @default [\"elysia\"]\n */\n readonly category?: string | readonly string[];\n\n /**\n * The log level to use for request logging.\n * @default \"info\"\n */\n readonly level?: LogLevel;\n\n /**\n * The format for log output.\n * Can be a predefined format name or a custom format function.\n *\n * Predefined formats:\n * - `\"combined\"` - Apache Combined Log Format (structured, default)\n * - `\"common\"` - Apache Common Log Format (structured, no referrer/userAgent)\n * - `\"dev\"` - Concise colored output for development (string)\n * - `\"short\"` - Shorter than common (string)\n * - `\"tiny\"` - Minimal output (string)\n *\n * @default \"combined\"\n */\n readonly format?: PredefinedFormat | FormatFunction;\n\n /**\n * Function to determine whether logging should be skipped.\n * Return `true` to skip logging for a request.\n *\n * @example Skip logging for health check endpoint\n * ```typescript\n * app.use(elysiaLogger({\n * skip: (ctx) => ctx.path === \"/health\",\n * }));\n * ```\n *\n * @default () => false\n */\n readonly skip?: (ctx: ElysiaContext) => boolean;\n\n /**\n * If `true`, logs are written immediately when the request is received.\n * If `false` (default), logs are written after the response is sent.\n *\n * Note: When `logRequest` is `true`, response-related properties\n * (status, responseTime, contentLength) will not be available.\n *\n * @default false\n */\n readonly logRequest?: boolean;\n\n /**\n * The plugin scope for controlling how lifecycle hooks are propagated.\n *\n * - `\"global\"` - Hooks apply to all routes in the application\n * - `\"scoped\"` - Hooks apply to the parent instance where the plugin is used\n * - `\"local\"` - Hooks only apply within the plugin itself\n *\n * @default \"global\"\n */\n readonly scope?: PluginScope;\n\n /**\n * Enables request-scoped implicit context and request ID correlation.\n *\n * When set to `true`, the plugin reads the `x-request-id` header, generates\n * one when it is absent, writes it to the `x-request-id` response header,\n * and adds `requestId` to all LogTape records emitted while handling the\n * request.\n *\n * @default false\n * @since 2.2.0\n */\n readonly context?: boolean | RequestContextOptions;\n}\n\nconst defaultRequestIdHeader = \"x-request-id\";\n\n/**\n * Per-request context state stored outside Elysia's shared store.\n */\ninterface ElysiaRequestContextState {\n readonly context: Record<string, unknown>;\n readonly startTime?: number;\n readonly responseHeader?: {\n readonly name: string;\n readonly value: string;\n };\n readonly set?: ElysiaContext[\"set\"];\n}\n\n/**\n * Normalize request context options.\n */\nfunction normalizeRequestContextOptions(\n options: boolean | RequestContextOptions | undefined,\n): RequestContextOptions | undefined {\n if (options === true) return {};\n if (options === false || options == null) return undefined;\n return options;\n}\n\n/**\n * Normalize request ID options.\n */\nfunction normalizeRequestIdOptions(\n options: boolean | RequestIdOptions | undefined,\n): RequestIdOptions | undefined {\n if (options === false) return undefined;\n if (options === true || options == null) return {};\n return options;\n}\n\n/**\n * Generate a request ID with Web Crypto when possible.\n */\nfunction generateRequestId(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\n/**\n * Normalize an incoming request ID.\n */\nfunction defaultNormalizeRequestId(value: string): string | null {\n const trimmed = value.trim();\n return trimmed === \"\" ? null : trimmed;\n}\n\n/**\n * Resolve a request path from a request URL.\n */\nfunction getPath(request: Request): string {\n return new URL(request.url, \"http://localhost\").pathname;\n}\n\n/**\n * Resolve the request ID for a request.\n */\nfunction resolveRequestId(\n request: Request,\n options: RequestIdOptions,\n): {\n readonly property: string;\n readonly value: string;\n readonly responseHeader?: string;\n} {\n const property = options.property ?? \"requestId\";\n const normalize = options.normalize ?? defaultNormalizeRequestId;\n const headerNames = options.headerNames ?? [defaultRequestIdHeader];\n for (const headerName of headerNames) {\n const headerValue = request.headers.get(headerName);\n if (headerValue == null) continue;\n const normalized = normalize(headerValue);\n if (normalized != null) {\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n return {\n property,\n value: normalized,\n responseHeader: responseHeader === false ? undefined : responseHeader,\n };\n }\n }\n const generated = (options.generate ?? generateRequestId)();\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n return {\n property,\n value: generated,\n responseHeader: responseHeader === false ? undefined : responseHeader,\n };\n}\n\n/**\n * Get referrer from request headers.\n */\nfunction getReferrer(request: Request): string | undefined {\n return request.headers.get(\"referrer\") ??\n request.headers.get(\"referer\") ??\n undefined;\n}\n\n/**\n * Get user agent from request headers.\n */\nfunction getUserAgent(request: Request): string | undefined {\n return request.headers.get(\"user-agent\") ?? undefined;\n}\n\n/**\n * Get remote address from X-Forwarded-For header.\n */\nfunction getRemoteAddr(request: Request): string | undefined {\n const forwarded = request.headers.get(\"x-forwarded-for\");\n if (forwarded) {\n // X-Forwarded-For can contain multiple IPs, take the first one\n const firstIp = forwarded.split(\",\")[0].trim();\n return firstIp || undefined;\n }\n return undefined;\n}\n\n/**\n * Build request context fields from a request.\n */\nfunction buildIncludedContext(\n request: Request,\n resolvedRequestId:\n | { readonly property: string; readonly value: string }\n | undefined,\n include: readonly RequestContextField[],\n): Record<string, unknown> {\n const context: Record<string, unknown> = {};\n for (const field of include) {\n switch (field) {\n case \"requestId\":\n if (resolvedRequestId != null) {\n context[resolvedRequestId.property] = resolvedRequestId.value;\n }\n break;\n case \"method\":\n context.method = request.method;\n break;\n case \"url\":\n context.url = request.url;\n break;\n case \"path\":\n context.path = getPath(request);\n break;\n case \"userAgent\":\n context.userAgent = getUserAgent(request);\n break;\n case \"remoteAddr\":\n context.remoteAddr = getRemoteAddr(request);\n break;\n case \"referrer\":\n context.referrer = getReferrer(request);\n break;\n }\n }\n return context;\n}\n\n/**\n * Build the implicit context for a request.\n */\nasync function buildRequestContext(\n request: Request,\n options: RequestContextOptions,\n): Promise<ElysiaRequestContextState> {\n const requestIdOptions = normalizeRequestIdOptions(options.requestId);\n const resolvedRequestId = requestIdOptions == null\n ? undefined\n : resolveRequestId(request, requestIdOptions);\n const include = options.include ??\n (resolvedRequestId == null ? [] : [\"requestId\"] as const);\n const context = buildIncludedContext(request, resolvedRequestId, include);\n let set: ElysiaContext[\"set\"] | undefined;\n if (options.enrich != null) {\n set = { status: 200, headers: {} };\n Object.assign(\n context,\n await options.enrich({\n request,\n path: getPath(request),\n set,\n }),\n );\n }\n const responseHeader = resolvedRequestId?.responseHeader == null\n ? undefined\n : {\n name: resolvedRequestId.responseHeader,\n value: resolvedRequestId.value,\n };\n return { context, responseHeader, set };\n}\n\n/**\n * Get content length from response headers.\n */\nfunction getContentLength(\n headers: Record<string, string | undefined>,\n): string | undefined {\n const contentLength = headers[\"content-length\"];\n if (contentLength === undefined || contentLength === null) return undefined;\n return contentLength;\n}\n\n/**\n * Build structured log properties from context.\n */\nfunction buildProperties(\n ctx: ElysiaContext,\n responseTime: number,\n): RequestLogProperties {\n return {\n method: ctx.request.method,\n url: ctx.request.url,\n path: ctx.path,\n status: ctx.set.status,\n responseTime,\n contentLength: getContentLength(ctx.set.headers),\n remoteAddr: getRemoteAddr(ctx.request),\n userAgent: getUserAgent(ctx.request),\n referrer: getReferrer(ctx.request),\n };\n}\n\n/**\n * Add request context fields to a request log result.\n */\nfunction withRequestLogContext(\n result: string | Record<string, unknown>,\n context: Record<string, unknown>,\n): string | Record<string, unknown> {\n if (typeof result === \"string\") return result;\n return { ...result, ...context };\n}\n\n/**\n * Combined format (Apache Combined Log Format).\n * Returns all structured properties.\n */\nfunction formatCombined(\n ctx: ElysiaContext,\n responseTime: number,\n): Record<string, unknown> {\n return { ...buildProperties(ctx, responseTime) };\n}\n\n/**\n * Common format (Apache Common Log Format).\n * Like combined but without referrer and userAgent.\n */\nfunction formatCommon(\n ctx: ElysiaContext,\n responseTime: number,\n): Record<string, unknown> {\n const props = buildProperties(ctx, responseTime);\n const { referrer: _referrer, userAgent: _userAgent, ...rest } = props;\n return rest;\n}\n\n/**\n * Dev format (colored output for development).\n * :method :path :status :response-time ms - :res[content-length]\n */\nfunction formatDev(ctx: ElysiaContext, responseTime: number): string {\n const contentLength = getContentLength(ctx.set.headers) ?? \"-\";\n return `${ctx.request.method} ${ctx.path} ${ctx.set.status} ${\n responseTime.toFixed(3)\n } ms - ${contentLength}`;\n}\n\n/**\n * Short format.\n * :remote-addr :method :url :status :res[content-length] - :response-time ms\n */\nfunction formatShort(ctx: ElysiaContext, responseTime: number): string {\n const remoteAddr = getRemoteAddr(ctx.request) ?? \"-\";\n const contentLength = getContentLength(ctx.set.headers) ?? \"-\";\n return `${remoteAddr} ${ctx.request.method} ${ctx.request.url} ${ctx.set.status} ${contentLength} - ${\n responseTime.toFixed(3)\n } ms`;\n}\n\n/**\n * Tiny format (minimal output).\n * :method :path :status :res[content-length] - :response-time ms\n */\nfunction formatTiny(ctx: ElysiaContext, responseTime: number): string {\n const contentLength = getContentLength(ctx.set.headers) ?? \"-\";\n return `${ctx.request.method} ${ctx.path} ${ctx.set.status} ${contentLength} - ${\n responseTime.toFixed(3)\n } ms`;\n}\n\n/**\n * Map of predefined format functions.\n */\nconst predefinedFormats: Record<PredefinedFormat, FormatFunction> = {\n combined: formatCombined,\n common: formatCommon,\n dev: formatDev,\n short: formatShort,\n tiny: formatTiny,\n};\n\n/**\n * Normalize category to array format.\n */\nfunction normalizeCategory(\n category: string | readonly string[],\n): readonly string[] {\n return typeof category === \"string\" ? [category] : category;\n}\n\n/**\n * Mapping of Elysia error codes to HTTP status codes.\n */\nconst errorCodeToStatus: Record<string, number> = {\n NOT_FOUND: 404,\n VALIDATION: 422,\n PARSE: 400,\n INTERNAL_SERVER_ERROR: 500,\n INVALID_COOKIE_SIGNATURE: 400,\n UNKNOWN: 500,\n};\n\n/**\n * Get the HTTP status code from an error context.\n * Checks error.status first, then falls back to error code mapping.\n */\nfunction getErrorStatus(\n code: string | number,\n error: unknown,\n setStatus: number,\n): number {\n // If code is already a number, use it as status\n if (typeof code === \"number\") {\n return code;\n }\n // Check if error has a status property (Elysia custom errors)\n if (\n error != null &&\n typeof error === \"object\" &&\n \"status\" in error &&\n typeof error.status === \"number\"\n ) {\n return error.status;\n }\n // Fall back to error code mapping\n if (code in errorCodeToStatus) {\n return errorCodeToStatus[code];\n }\n // Use set.status as last resort\n return setStatus;\n}\n\n/**\n * Internal store type for timing.\n */\ninterface LoggerStore {\n startTime: number;\n}\n\ntype ElysiaRouteContext = ElysiaContext & {\n readonly store: LoggerStore;\n};\n\ntype ElysiaRequestCallback = (\n this: unknown,\n ...args: unknown[]\n) => unknown;\n\ntype ElysiaRouteRegistrar = (\n path: string,\n handler: unknown,\n hook?: unknown,\n) => unknown;\n\ntype ElysiaUseRegistrar = (\n plugin: unknown,\n ...options: unknown[]\n) => unknown;\n\ntype ElysiaRouteMethod =\n | \"all\"\n | \"connect\"\n | \"delete\"\n | \"get\"\n | \"head\"\n | \"options\"\n | \"patch\"\n | \"post\"\n | \"put\";\n\nconst elysiaRouteMethods: readonly ElysiaRouteMethod[] = [\n \"all\",\n \"connect\",\n \"delete\",\n \"get\",\n \"head\",\n \"options\",\n \"patch\",\n \"post\",\n \"put\",\n];\n\nconst elysiaRouteHookKeys = [\n \"afterHandle\",\n \"afterResponse\",\n \"beforeHandle\",\n \"derive\",\n \"error\",\n \"mapResponse\",\n \"parse\",\n \"resolve\",\n \"transform\",\n] as const;\n\ntype ElysiaRoutePlugin = Record<ElysiaRouteMethod, ElysiaRouteRegistrar> & {\n readonly router?: {\n readonly history?: Record<string, ElysiaRouteEntry> | ElysiaRouteEntry[];\n };\n route: (\n method: string,\n path: string,\n handler: unknown,\n hook?: unknown,\n ) => unknown;\n use: ElysiaUseRegistrar;\n};\n\ninterface ElysiaRouteEntry {\n handler?: unknown;\n hooks?: unknown;\n}\n\nfunction getElysiaRouteEntries(plugin: unknown): ElysiaRouteEntry[] {\n if (plugin == null || typeof plugin !== \"object\") return [];\n const routePlugin = plugin as {\n readonly default?: unknown;\n readonly router?: {\n readonly history?: Record<string, ElysiaRouteEntry> | ElysiaRouteEntry[];\n };\n };\n const history = routePlugin.router?.history;\n const entries = Array.isArray(history)\n ? history\n : history == null\n ? []\n : Object.values(history);\n return entries.concat(getElysiaRouteEntries(routePlugin.default));\n}\n\n/**\n * Wrap routes registered on a local plugin with implicit LogTape context.\n */\nfunction wrapLocalRouteHandlers(\n plugin: ElysiaRoutePlugin,\n buildAndStoreRequestContext: (\n request: Request,\n ) => Promise<ElysiaRequestContextState | undefined>,\n applyRequestContextToSet: (\n set: ElysiaContext[\"set\"],\n requestContext: ElysiaRequestContextState | undefined,\n ) => void,\n): void {\n const wrappedHandlers = new WeakSet<ElysiaRequestCallback>();\n const wrappedHandlerCache = new WeakMap<\n ElysiaRequestCallback,\n ElysiaRequestCallback\n >();\n\n const getRouteContext = (\n value: unknown,\n ): ElysiaRouteContext | undefined => {\n if (value == null || typeof value !== \"object\") return undefined;\n const context = value as { readonly request?: unknown };\n if (!(context.request instanceof Request)) return undefined;\n return value as ElysiaRouteContext;\n };\n\n const wrapRequestCallback = (callback: unknown): unknown => {\n if (typeof callback !== \"function\") return callback;\n const requestCallback = callback as ElysiaRequestCallback;\n if (wrappedHandlers.has(requestCallback)) return callback;\n const cached = wrappedHandlerCache.get(requestCallback);\n if (cached != null) return cached;\n const wrapped = async function (\n this: unknown,\n ...args: unknown[]\n ): Promise<unknown> {\n const ctx = getRouteContext(args[0]);\n if (ctx == null) return await requestCallback.apply(this, args);\n const requestContext = await buildAndStoreRequestContext(ctx.request);\n ctx.store.startTime = requestContext?.startTime ??\n performance.now();\n applyRequestContextToSet(ctx.set, requestContext);\n return await withContext(\n requestContext?.context ?? {},\n () => requestCallback.apply(this, args),\n );\n };\n wrappedHandlers.add(wrapped);\n wrappedHandlerCache.set(requestCallback, wrapped);\n return wrapped;\n };\n\n const wrapRouteHookValue = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(wrapRouteHookValue);\n if (typeof value === \"function\") return wrapRequestCallback(value);\n if (value == null || typeof value !== \"object\") return value;\n const hookContainer = value as { readonly fn?: unknown };\n if (typeof hookContainer.fn !== \"function\") return value;\n return {\n ...hookContainer,\n fn: wrapRequestCallback(hookContainer.fn),\n };\n };\n\n const wrapRouteHooks = (hooks: unknown): unknown => {\n if (hooks == null || typeof hooks !== \"object\") return hooks;\n const routeHooks = hooks as Record<string, unknown>;\n let changed = false;\n const wrappedHooks = { ...routeHooks };\n for (const key of elysiaRouteHookKeys) {\n const value = routeHooks[key];\n const wrappedValue = wrapRouteHookValue(value);\n if (wrappedValue === value) continue;\n wrappedHooks[key] = wrappedValue;\n changed = true;\n }\n return changed ? wrappedHooks : hooks;\n };\n\n const wrapRouteEntries = (routePlugin: unknown): (() => void)[] => {\n const restore: (() => void)[] = [];\n for (const route of getElysiaRouteEntries(routePlugin)) {\n const handler = route.handler;\n const wrappedHandler = wrapRequestCallback(handler);\n if (wrappedHandler !== handler) {\n route.handler = wrappedHandler;\n restore.push(() => {\n route.handler = handler;\n });\n }\n const hooks = route.hooks;\n const wrappedHooks = wrapRouteHooks(hooks);\n if (wrappedHooks !== hooks) {\n route.hooks = wrappedHooks;\n restore.push(() => {\n route.hooks = hooks;\n });\n }\n }\n return restore;\n };\n\n for (const method of elysiaRouteMethods) {\n const register = plugin[method].bind(plugin);\n plugin[method] = ((path: string, handler: unknown, hook?: unknown) =>\n register(\n path,\n wrapRequestCallback(handler),\n wrapRouteHooks(hook),\n )) as ElysiaRouteRegistrar;\n }\n\n const route = plugin.route.bind(plugin);\n plugin.route = ((\n method: string,\n path: string,\n handler: unknown,\n hook?: unknown,\n ) =>\n route(\n method,\n path,\n wrapRequestCallback(handler),\n wrapRouteHooks(hook),\n )) as ElysiaRoutePlugin[\"route\"];\n\n const use = plugin.use.bind(plugin);\n plugin.use = ((childPlugin: unknown, ...options: unknown[]) => {\n const restore = wrapRouteEntries(childPlugin);\n try {\n return use(childPlugin, ...options);\n } finally {\n for (const restoreRouteHandler of restore) restoreRouteHandler();\n }\n }) as ElysiaUseRegistrar;\n}\n\n/**\n * Creates Elysia plugin for HTTP request logging using LogTape.\n *\n * This plugin provides Morgan-compatible request logging with LogTape\n * as the backend, supporting structured logging and customizable formats.\n *\n * @example Basic usage\n * ```typescript\n * import { Elysia } from \"elysia\";\n * import { configure, getConsoleSink } from \"@logtape/logtape\";\n * import { elysiaLogger } from \"@logtape/elysia\";\n *\n * await configure({\n * sinks: { console: getConsoleSink() },\n * loggers: [\n * { category: [\"elysia\"], sinks: [\"console\"], lowestLevel: \"info\" }\n * ],\n * });\n *\n * const app = new Elysia()\n * .use(elysiaLogger())\n * .get(\"/\", () => ({ hello: \"world\" }))\n * .listen(3000);\n * ```\n *\n * @example With custom options\n * ```typescript\n * app.use(elysiaLogger({\n * category: [\"myapp\", \"http\"],\n * level: \"debug\",\n * format: \"dev\",\n * skip: (ctx) => ctx.path === \"/health\",\n * scope: \"scoped\",\n * }));\n * ```\n *\n * @example With custom format function\n * ```typescript\n * app.use(elysiaLogger({\n * format: (ctx, responseTime) => ({\n * method: ctx.request.method,\n * path: ctx.path,\n * status: ctx.set.status,\n * duration: responseTime,\n * }),\n * }));\n * ```\n *\n * @param options Configuration options for the plugin.\n * @returns Elysia plugin instance.\n * @since 2.0.0\n */\n// deno-lint-ignore no-explicit-any\nexport function elysiaLogger(options: ElysiaLogTapeOptions = {}): Elysia<any> {\n const category = normalizeCategory(options.category ?? [\"elysia\"]);\n const logger = getLogger(category);\n const level = options.level ?? \"info\";\n const formatOption = options.format ?? \"combined\";\n const skip = options.skip ?? (() => false);\n const logRequest = options.logRequest ?? false;\n const scope = options.scope ?? \"global\";\n const contextOptions = normalizeRequestContextOptions(options.context);\n const requestContextStates = new WeakMap<\n Request,\n ElysiaRequestContextState\n >();\n const shouldWrapContext = contextOptions != null;\n const shouldWrapAllRoutes = contextOptions != null && scope !== \"local\";\n\n // Resolve format function\n const formatFn: FormatFunction = typeof formatOption === \"string\"\n ? predefinedFormats[formatOption]\n : formatOption;\n\n const logMethod = logger[level].bind(logger);\n const errorLogMethod = logger.error.bind(logger);\n\n const buildAndStoreRequestContext = async (\n request: Request,\n ): Promise<ElysiaRequestContextState | undefined> => {\n if (contextOptions == null) return undefined;\n const existingContext = requestContextStates.get(request);\n if (existingContext != null) return existingContext;\n const startTime = performance.now();\n const requestContext = {\n ...await buildRequestContext(request, contextOptions),\n startTime,\n };\n requestContextStates.set(request, requestContext);\n return requestContext;\n };\n\n const applyRequestContextToSet = (\n set: ElysiaContext[\"set\"],\n requestContext: ElysiaRequestContextState | undefined,\n ): void => {\n if (requestContext?.responseHeader != null) {\n set.headers[requestContext.responseHeader.name] =\n requestContext.responseHeader.value;\n }\n if (requestContext?.set != null) {\n if (requestContext.set.status !== 200) {\n set.status = requestContext.set.status;\n }\n Object.assign(set.headers, requestContext.set.headers);\n }\n };\n\n // deno-lint-ignore no-explicit-any\n let plugin: Elysia<any, any, any, any, any, any, any> = new Elysia({\n name: \"@logtape/elysia\",\n seed: options,\n });\n\n if (shouldWrapContext && scope === \"local\") {\n wrapLocalRouteHandlers(\n plugin as unknown as ElysiaRoutePlugin,\n buildAndStoreRequestContext,\n applyRequestContextToSet,\n );\n } else if (shouldWrapContext) {\n // Elysia lifecycle hooks cannot wrap downstream handlers, so use wrap()\n // to keep AsyncLocalStorage active for the whole route execution.\n plugin = plugin.wrap((handle) => {\n return async (request: Request) => {\n const requestContext = await buildAndStoreRequestContext(request);\n return await withContext(\n requestContext?.context ?? {},\n () => handle(request),\n );\n };\n });\n }\n\n plugin = plugin\n .state(\"startTime\", 0)\n .onRequest(async ({ request, set, store }) => {\n let requestContext = requestContextStates.get(request);\n if (requestContext == null && shouldWrapAllRoutes) {\n requestContext = await buildAndStoreRequestContext(request);\n }\n (store as LoggerStore).startTime = requestContext?.startTime ??\n performance.now();\n applyRequestContextToSet(set, requestContext);\n });\n\n if (scope === \"local\" && (contextOptions != null || logRequest)) {\n plugin = plugin.onBeforeHandle(async (ctx) => {\n const requestContext = await buildAndStoreRequestContext(ctx.request);\n (ctx.store as LoggerStore).startTime = requestContext?.startTime ??\n performance.now();\n applyRequestContextToSet(ctx.set, requestContext);\n if (logRequest && !skip(ctx as unknown as ElysiaContext)) {\n const context = requestContext?.context ?? {};\n const result = withRequestLogContext(\n formatFn(ctx as unknown as ElysiaContext, 0),\n context,\n );\n if (typeof result === \"string\") {\n logMethod(result, context);\n } else {\n logMethod(\"{method} {url}\", result);\n }\n }\n });\n }\n\n if (logRequest) {\n // Log immediately when request arrives\n if (scope !== \"local\") {\n plugin = plugin.onRequest((ctx) => {\n if (!skip(ctx as unknown as ElysiaContext)) {\n const requestContext =\n requestContextStates.get(ctx.request)?.context ??\n {};\n const result = withRequestLogContext(\n formatFn(ctx as unknown as ElysiaContext, 0),\n requestContext,\n );\n if (typeof result === \"string\") {\n logMethod(result, requestContext);\n } else {\n logMethod(\"{method} {url}\", result);\n }\n }\n });\n }\n } else {\n // Log after handler completes\n plugin = plugin.onAfterHandle((ctx) => {\n if (skip(ctx as unknown as ElysiaContext)) return;\n\n const store = ctx.store as LoggerStore;\n const responseTime = performance.now() - store.startTime;\n const requestContext = requestContextStates.get(ctx.request)?.context ??\n {};\n const result = withRequestLogContext(\n formatFn(ctx as unknown as ElysiaContext, responseTime),\n requestContext,\n );\n\n if (typeof result === \"string\") {\n logMethod(result, requestContext);\n } else {\n logMethod(\"{method} {url} {status} - {responseTime} ms\", result);\n }\n });\n }\n\n // Add error logging\n plugin = plugin.onError((ctx) => {\n const store = ctx.store as LoggerStore;\n const responseTime = performance.now() - store.startTime;\n const elysiaCtx = ctx as unknown as ElysiaContext;\n\n if (skip(elysiaCtx)) return;\n\n const props = buildProperties(elysiaCtx, responseTime);\n const requestContext = requestContextStates.get(ctx.request)?.context ?? {};\n // Get the correct HTTP status code from error context\n const status = getErrorStatus(ctx.code, ctx.error, elysiaCtx.set.status);\n // Extract error message safely\n const error = ctx.error as { message?: string } | undefined;\n const errorMessage = error?.message ?? \"Unknown error\";\n errorLogMethod(\n \"Error: {method} {url} {status} - {responseTime} ms - {errorMessage}\",\n {\n ...props,\n ...requestContext,\n status,\n errorMessage,\n errorCode: ctx.code,\n },\n );\n });\n\n // Apply scope\n if (scope === \"global\") {\n // deno-lint-ignore no-explicit-any\n return plugin.as(\"global\") as unknown as Elysia<any>;\n } else if (scope === \"scoped\") {\n // deno-lint-ignore no-explicit-any\n return plugin.as(\"scoped\") as unknown as Elysia<any>;\n }\n\n // deno-lint-ignore no-explicit-any\n return plugin as unknown as Elysia<any>;\n}\n"],"mappings":";;;;AAkOA,MAAM,yBAAyB;;;;AAkB/B,SAAS,+BACPA,SACmC;AACnC,KAAI,YAAY,KAAM,QAAO,CAAE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2.0-dev.702+4879c273",
4
4
  "description": "Elysia adapter for LogTape logging library",
5
5
  "keywords": [
6
6
  "logging",
@@ -54,7 +54,7 @@
54
54
  ],
55
55
  "peerDependencies": {
56
56
  "elysia": "^1.4.0",
57
- "@logtape/logtape": "^2.2.0-dev.700+748dd292"
57
+ "@logtape/logtape": "^2.2.0-dev.702+4879c273"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@alinea/suite": "^0.6.3",