@logtape/express 2.2.0-dev.766 → 2.2.0-dev.767

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/README.md CHANGED
@@ -116,11 +116,19 @@ app.use(expressLogger({
116
116
  Predefined formats
117
117
  ------------------
118
118
 
119
- - **combined**: Apache Combined Log Format with all properties (default)
120
- - **common**: Apache Common Log Format (without referrer/userAgent)
121
- - **dev**: Concise output for development (`GET /path 200 1.234 ms - 123`)
122
- - **short**: Shorter format with remote address
123
- - **tiny**: Minimal output
119
+ The middleware supports structured presets and text presets:
120
+
121
+ - `"structured-combined"`: Structured request properties with all fields
122
+ (default)
123
+ - `"structured-common"`: Structured request properties without
124
+ `referrer`/`userAgent`
125
+ - `"combined"`: Deprecated alias for `"structured-combined"`
126
+ - `"common"`: Deprecated alias for `"structured-common"`
127
+ - `"morgan-combined"`: Morgan-compatible Apache combined access log output
128
+ - `"morgan-common"`: Morgan-compatible Apache common access log output
129
+ - `"dev"`: Concise output for development (`GET /path 200 1.234 ms - 123`)
130
+ - `"short"`: Shorter format with remote address
131
+ - `"tiny"`: Minimal output
124
132
 
125
133
 
126
134
  Custom format function
package/dist/mod.cjs CHANGED
@@ -129,6 +129,53 @@ function withRequestLogContext(result, context) {
129
129
  ...context
130
130
  };
131
131
  }
132
+ const clfMonths = [
133
+ "Jan",
134
+ "Feb",
135
+ "Mar",
136
+ "Apr",
137
+ "May",
138
+ "Jun",
139
+ "Jul",
140
+ "Aug",
141
+ "Sep",
142
+ "Oct",
143
+ "Nov",
144
+ "Dec"
145
+ ];
146
+ function pad2(value) {
147
+ return value.toString().padStart(2, "0");
148
+ }
149
+ function formatClfDate(timestamp = Date.now()) {
150
+ const date = new Date(timestamp);
151
+ return `${pad2(date.getUTCDate())}/${clfMonths[date.getUTCMonth()]}/${date.getUTCFullYear()}:${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}:${pad2(date.getUTCSeconds())} +0000`;
152
+ }
153
+ function escapeAccessLogValue(value, escapeSpaces) {
154
+ const escaped = String(value).replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
155
+ return escapeSpaces ? escaped.replace(/ /g, "\\x20") : escaped;
156
+ }
157
+ function formatAccessLogToken(value) {
158
+ if (value == null || value === "") return "-";
159
+ return escapeAccessLogValue(value, true);
160
+ }
161
+ function formatAccessLogQuotedToken(value) {
162
+ if (value == null || value === "") return "\"-\"";
163
+ return `"${escapeAccessLogValue(value, false)}"`;
164
+ }
165
+ function getRemoteUser(req) {
166
+ const authorization = req.get("authorization");
167
+ if (authorization == null) return void 0;
168
+ const match = /^Basic\s+(.+)$/i.exec(authorization);
169
+ if (match == null || typeof globalThis.atob !== "function") return void 0;
170
+ try {
171
+ const decoded = globalThis.atob(match[1]);
172
+ const colonIndex = decoded.indexOf(":");
173
+ const user = colonIndex < 0 ? decoded : decoded.slice(0, colonIndex);
174
+ return user === "" ? void 0 : user;
175
+ } catch {
176
+ return void 0;
177
+ }
178
+ }
132
179
  /**
133
180
  * Get remote address from request.
134
181
  */
@@ -172,15 +219,15 @@ function buildProperties(req, res, responseTime) {
172
219
  };
173
220
  }
174
221
  /**
175
- * Combined format (Apache Combined Log Format).
222
+ * Structured combined format.
176
223
  * Returns all structured properties.
177
224
  */
178
225
  function formatCombined(req, res, responseTime) {
179
226
  return { ...buildProperties(req, res, responseTime) };
180
227
  }
181
228
  /**
182
- * Common format (Apache Common Log Format).
183
- * Like combined but without referrer and userAgent.
229
+ * Structured common format.
230
+ * Like structured combined but without referrer and userAgent.
184
231
  */
185
232
  function formatCommon(req, res, responseTime) {
186
233
  const props = buildProperties(req, res, responseTime);
@@ -188,6 +235,23 @@ function formatCommon(req, res, responseTime) {
188
235
  return rest;
189
236
  }
190
237
  /**
238
+ * Morgan combined format.
239
+ * :remote-addr - :remote-user [:date[clf]]
240
+ * ":method :url HTTP/:http-version" :status :res[content-length]
241
+ * ":referrer" ":user-agent"
242
+ */
243
+ function formatMorganCombined(req, res) {
244
+ return `${formatAccessLogToken(getRemoteAddr(req))} - ${formatAccessLogToken(getRemoteUser(req))} [${formatClfDate()}] "${formatAccessLogToken(req.method)} ${formatAccessLogToken(req.originalUrl || req.url)} HTTP/${formatAccessLogToken(req.httpVersion)}" ${formatAccessLogToken(res.statusCode)} ${formatAccessLogToken(getContentLength(res))} ${formatAccessLogQuotedToken(getReferrer(req))} ${formatAccessLogQuotedToken(getUserAgent(req))}`;
245
+ }
246
+ /**
247
+ * Morgan common format.
248
+ * :remote-addr - :remote-user [:date[clf]]
249
+ * ":method :url HTTP/:http-version" :status :res[content-length]
250
+ */
251
+ function formatMorganCommon(req, res) {
252
+ return `${formatAccessLogToken(getRemoteAddr(req))} - ${formatAccessLogToken(getRemoteUser(req))} [${formatClfDate()}] "${formatAccessLogToken(req.method)} ${formatAccessLogToken(req.originalUrl || req.url)} HTTP/${formatAccessLogToken(req.httpVersion)}" ${formatAccessLogToken(res.statusCode)} ${formatAccessLogToken(getContentLength(res))}`;
253
+ }
254
+ /**
191
255
  * Dev format (colored output for development).
192
256
  * :method :url :status :response-time ms - :res[content-length]
193
257
  */
@@ -218,6 +282,10 @@ function formatTiny(req, res, responseTime) {
218
282
  const predefinedFormats = {
219
283
  combined: formatCombined,
220
284
  common: formatCommon,
285
+ "structured-combined": formatCombined,
286
+ "structured-common": formatCommon,
287
+ "morgan-combined": formatMorganCombined,
288
+ "morgan-common": formatMorganCommon,
221
289
  dev: formatDev,
222
290
  short: formatShort,
223
291
  tiny: formatTiny
@@ -287,7 +355,7 @@ function expressLogger(options = {}) {
287
355
  const category = normalizeCategory(options.category ?? ["express"]);
288
356
  const logger = (0, __logtape_logtape.getLogger)(category);
289
357
  const level = options.level ?? "info";
290
- const formatOption = options.format ?? "combined";
358
+ const formatOption = options.format ?? "structured-combined";
291
359
  const skip = options.skip ?? (() => false);
292
360
  const immediate = options.immediate ?? false;
293
361
  const contextOptions = normalizeRequestContextOptions(options.context);
package/dist/mod.d.cts CHANGED
@@ -39,10 +39,17 @@ type ExpressNextFunction = (err?: unknown) => void;
39
39
  */
40
40
  type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
41
41
  /**
42
- * Predefined log format names compatible with Morgan.
42
+ * Predefined log format names.
43
43
  * @since 1.3.0
44
44
  */
45
- type PredefinedFormat = "combined" | "common" | "dev" | "short" | "tiny";
45
+ type PredefinedFormat =
46
+ /**
47
+ * @deprecated Use `"structured-combined"` instead.
48
+ */
49
+ "combined"
50
+ /**
51
+ * @deprecated Use `"structured-common"` instead.
52
+ */ | "common" | "structured-combined" | "structured-common" | "morgan-combined" | "morgan-common" | "dev" | "short" | "tiny";
46
53
  /**
47
54
  * Custom format function for request logging.
48
55
  *
@@ -153,14 +160,21 @@ interface ExpressLogTapeOptions {
153
160
  * The format for log output.
154
161
  * Can be a predefined format name or a custom format function.
155
162
  *
156
- * Predefined formats:
157
- * - `"combined"` - Apache Combined Log Format (structured, default)
158
- * - `"common"` - Apache Common Log Format (structured, no referrer/userAgent)
163
+ * Structured formats:
164
+ * - `"structured-combined"` - All structured request properties (default)
165
+ * - `"structured-common"` - Structured request properties without
166
+ * referrer/userAgent
167
+ * - `"combined"` - Deprecated alias for `"structured-combined"`
168
+ * - `"common"` - Deprecated alias for `"structured-common"`
169
+ *
170
+ * Text formats:
171
+ * - `"morgan-combined"` - Morgan-compatible combined access log (string)
172
+ * - `"morgan-common"` - Morgan-compatible common access log (string)
159
173
  * - `"dev"` - Concise colored output for development (string)
160
174
  * - `"short"` - Shorter than common (string)
161
175
  * - `"tiny"` - Minimal output (string)
162
176
  *
163
- * @default "combined"
177
+ * @default "structured-combined"
164
178
  */
165
179
  readonly format?: PredefinedFormat | FormatFunction;
166
180
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAWA;AAeA;AAWA;AA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;;;AAwB4B;AAodpD;AAA6B,KAtqBjB,gBAAA;;;AAwqBQ;;;;;;;;;;;;;;KA9oBR,cAAA,SACL,qBACA,mDAEO;;;;;UAMG,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;KAyBL,mBAAA;;;;;UAcK,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAqCA,qBAAA;;;;;iCAKgB;;;;;8BAMH;;;;0BAMrB,qBACA,oBACF,0BAA0B,QAAQ;;;;;;UAOxB,qBAAA;;;;;;;;;;mBAWE;;;;;;;;;;;;;;;;;;;;;oBAsBC,mBAAmB;;;;;;;;;;;;;;wBAef,qBAAqB;;;;;;;;;;;;;;;;;;;;;;+BAwBd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAodf,aAAA,WACL,wBACR"}
package/dist/mod.d.ts CHANGED
@@ -39,10 +39,17 @@ type ExpressNextFunction = (err?: unknown) => void;
39
39
  */
40
40
  type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
41
41
  /**
42
- * Predefined log format names compatible with Morgan.
42
+ * Predefined log format names.
43
43
  * @since 1.3.0
44
44
  */
45
- type PredefinedFormat = "combined" | "common" | "dev" | "short" | "tiny";
45
+ type PredefinedFormat =
46
+ /**
47
+ * @deprecated Use `"structured-combined"` instead.
48
+ */
49
+ "combined"
50
+ /**
51
+ * @deprecated Use `"structured-common"` instead.
52
+ */ | "common" | "structured-combined" | "structured-common" | "morgan-combined" | "morgan-common" | "dev" | "short" | "tiny";
46
53
  /**
47
54
  * Custom format function for request logging.
48
55
  *
@@ -153,14 +160,21 @@ interface ExpressLogTapeOptions {
153
160
  * The format for log output.
154
161
  * Can be a predefined format name or a custom format function.
155
162
  *
156
- * Predefined formats:
157
- * - `"combined"` - Apache Combined Log Format (structured, default)
158
- * - `"common"` - Apache Common Log Format (structured, no referrer/userAgent)
163
+ * Structured formats:
164
+ * - `"structured-combined"` - All structured request properties (default)
165
+ * - `"structured-common"` - Structured request properties without
166
+ * referrer/userAgent
167
+ * - `"combined"` - Deprecated alias for `"structured-combined"`
168
+ * - `"common"` - Deprecated alias for `"structured-common"`
169
+ *
170
+ * Text formats:
171
+ * - `"morgan-combined"` - Morgan-compatible combined access log (string)
172
+ * - `"morgan-common"` - Morgan-compatible common access log (string)
159
173
  * - `"dev"` - Concise colored output for development (string)
160
174
  * - `"short"` - Shorter than common (string)
161
175
  * - `"tiny"` - Minimal output (string)
162
176
  *
163
- * @default "combined"
177
+ * @default "structured-combined"
164
178
  */
165
179
  readonly format?: PredefinedFormat | FormatFunction;
166
180
  /**
package/dist/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAWA;AAeA;AAWA;AAMY,UAhCK,cAAA,CAgCY;EAAA,MAAA,EAAA,MAAA;EAAA,GACtB,EAAA,MAAA;EAAc,WACd,CAAA,EAAA,MAAA;EAAe,IACd,CAAA,EAAA,MAAA;EAAmB,WAAA,EAAA,MAAA;EAOf,EAAA,CAAA,EAAA,MAAA;EAWA,MAAA,CAAA,EAAA;IAAc,aAAA,CAAA,EAAA,MAAA;EAAA,CAAA;EACL,GACd,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,SAAA;;AAEa;AAMpB;AAyBA;AAcA;AAqCiB,UA5HA,eAAA,CA4HqB;EAAA,UAAA,EAAA,MAAA;EAAA,EAAA,CAKL,KAAA,EAAA,MAAA,EAAA,QAAA,EAAA,GAAA,GAAA,IAAA,CAAA,EAAA,IAAA;EAAgB,SAMnB,CAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;EAAmB,SAMxC,EAAA,IAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;AAE+B;AAOvB,KA3IL,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A,eAAA,CA2IqB;EAAA,UAAA,EAAA,MAAA;EAAA,EAAA,CAKL,KAAA,EAAA,MAAA,EAAA,QAAA,EAAA,GAAA,GAAA,IAAA,CAAA,EAAA,IAAA;EAAgB,SAMnB,CAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;EAAmB,SAMxC,EAAA,IAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;AAE+B;AAOvB,KA1JL,mBAAA,GA0J0B,CAAA,GAAA,CAAA,EAAA,OAAA,EAAA,GAAA,IAAA;;;;;AAgDd,KApMZ,iBAAA,GAoMY,CAAA,GAAA,EAnMjB,cAmMiB,EAAA,GAAA,EAlMjB,eAkMiB,EAAA,IAAA,EAjMhB,mBAiMgB,EAAA,GAAA,IAAA;;;AAwB4B;AAodpD;AAA6B,KAtqBjB,gBAAA;;;AAwqBQ;;;;;;;;;;;;;;KA9oBR,cAAA,SACL,qBACA,mDAEO;;;;;UAMG,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;KAyBL,mBAAA;;;;;UAcK,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAqCA,qBAAA;;;;;iCAKgB;;;;;8BAMH;;;;0BAMrB,qBACA,oBACF,0BAA0B,QAAQ;;;;;;UAOxB,qBAAA;;;;;;;;;;mBAWE;;;;;;;;;;;;;;;;;;;;;oBAsBC,mBAAmB;;;;;;;;;;;;;;wBAef,qBAAqB;;;;;;;;;;;;;;;;;;;;;;+BAwBd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAodf,aAAA,WACL,wBACR"}
package/dist/mod.js CHANGED
@@ -128,6 +128,53 @@ function withRequestLogContext(result, context) {
128
128
  ...context
129
129
  };
130
130
  }
131
+ const clfMonths = [
132
+ "Jan",
133
+ "Feb",
134
+ "Mar",
135
+ "Apr",
136
+ "May",
137
+ "Jun",
138
+ "Jul",
139
+ "Aug",
140
+ "Sep",
141
+ "Oct",
142
+ "Nov",
143
+ "Dec"
144
+ ];
145
+ function pad2(value) {
146
+ return value.toString().padStart(2, "0");
147
+ }
148
+ function formatClfDate(timestamp = Date.now()) {
149
+ const date = new Date(timestamp);
150
+ return `${pad2(date.getUTCDate())}/${clfMonths[date.getUTCMonth()]}/${date.getUTCFullYear()}:${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}:${pad2(date.getUTCSeconds())} +0000`;
151
+ }
152
+ function escapeAccessLogValue(value, escapeSpaces) {
153
+ const escaped = String(value).replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
154
+ return escapeSpaces ? escaped.replace(/ /g, "\\x20") : escaped;
155
+ }
156
+ function formatAccessLogToken(value) {
157
+ if (value == null || value === "") return "-";
158
+ return escapeAccessLogValue(value, true);
159
+ }
160
+ function formatAccessLogQuotedToken(value) {
161
+ if (value == null || value === "") return "\"-\"";
162
+ return `"${escapeAccessLogValue(value, false)}"`;
163
+ }
164
+ function getRemoteUser(req) {
165
+ const authorization = req.get("authorization");
166
+ if (authorization == null) return void 0;
167
+ const match = /^Basic\s+(.+)$/i.exec(authorization);
168
+ if (match == null || typeof globalThis.atob !== "function") return void 0;
169
+ try {
170
+ const decoded = globalThis.atob(match[1]);
171
+ const colonIndex = decoded.indexOf(":");
172
+ const user = colonIndex < 0 ? decoded : decoded.slice(0, colonIndex);
173
+ return user === "" ? void 0 : user;
174
+ } catch {
175
+ return void 0;
176
+ }
177
+ }
131
178
  /**
132
179
  * Get remote address from request.
133
180
  */
@@ -171,15 +218,15 @@ function buildProperties(req, res, responseTime) {
171
218
  };
172
219
  }
173
220
  /**
174
- * Combined format (Apache Combined Log Format).
221
+ * Structured combined format.
175
222
  * Returns all structured properties.
176
223
  */
177
224
  function formatCombined(req, res, responseTime) {
178
225
  return { ...buildProperties(req, res, responseTime) };
179
226
  }
180
227
  /**
181
- * Common format (Apache Common Log Format).
182
- * Like combined but without referrer and userAgent.
228
+ * Structured common format.
229
+ * Like structured combined but without referrer and userAgent.
183
230
  */
184
231
  function formatCommon(req, res, responseTime) {
185
232
  const props = buildProperties(req, res, responseTime);
@@ -187,6 +234,23 @@ function formatCommon(req, res, responseTime) {
187
234
  return rest;
188
235
  }
189
236
  /**
237
+ * Morgan combined format.
238
+ * :remote-addr - :remote-user [:date[clf]]
239
+ * ":method :url HTTP/:http-version" :status :res[content-length]
240
+ * ":referrer" ":user-agent"
241
+ */
242
+ function formatMorganCombined(req, res) {
243
+ return `${formatAccessLogToken(getRemoteAddr(req))} - ${formatAccessLogToken(getRemoteUser(req))} [${formatClfDate()}] "${formatAccessLogToken(req.method)} ${formatAccessLogToken(req.originalUrl || req.url)} HTTP/${formatAccessLogToken(req.httpVersion)}" ${formatAccessLogToken(res.statusCode)} ${formatAccessLogToken(getContentLength(res))} ${formatAccessLogQuotedToken(getReferrer(req))} ${formatAccessLogQuotedToken(getUserAgent(req))}`;
244
+ }
245
+ /**
246
+ * Morgan common format.
247
+ * :remote-addr - :remote-user [:date[clf]]
248
+ * ":method :url HTTP/:http-version" :status :res[content-length]
249
+ */
250
+ function formatMorganCommon(req, res) {
251
+ return `${formatAccessLogToken(getRemoteAddr(req))} - ${formatAccessLogToken(getRemoteUser(req))} [${formatClfDate()}] "${formatAccessLogToken(req.method)} ${formatAccessLogToken(req.originalUrl || req.url)} HTTP/${formatAccessLogToken(req.httpVersion)}" ${formatAccessLogToken(res.statusCode)} ${formatAccessLogToken(getContentLength(res))}`;
252
+ }
253
+ /**
190
254
  * Dev format (colored output for development).
191
255
  * :method :url :status :response-time ms - :res[content-length]
192
256
  */
@@ -217,6 +281,10 @@ function formatTiny(req, res, responseTime) {
217
281
  const predefinedFormats = {
218
282
  combined: formatCombined,
219
283
  common: formatCommon,
284
+ "structured-combined": formatCombined,
285
+ "structured-common": formatCommon,
286
+ "morgan-combined": formatMorganCombined,
287
+ "morgan-common": formatMorganCommon,
220
288
  dev: formatDev,
221
289
  short: formatShort,
222
290
  tiny: formatTiny
@@ -286,7 +354,7 @@ function expressLogger(options = {}) {
286
354
  const category = normalizeCategory(options.category ?? ["express"]);
287
355
  const logger = getLogger(category);
288
356
  const level = options.level ?? "info";
289
- const formatOption = options.format ?? "combined";
357
+ const formatOption = options.format ?? "structured-combined";
290
358
  const skip = options.skip ?? (() => false);
291
359
  const immediate = options.immediate ?? false;
292
360
  const contextOptions = normalizeRequestContextOptions(options.context);
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","req: ExpressRequest","res: ExpressResponse","options: RequestIdOptions","responseHeader","resolvedRequestId: { property: string; value: string } | undefined","include: readonly RequestContextField[]","context: Record<string, unknown>","value: unknown","options: RequestContextOptions","result: string | Record<string, unknown>","responseTime: number","predefinedFormats: Record<PredefinedFormat, FormatFunction>","category: string | readonly string[]","options: ExpressLogTapeOptions","formatFn: FormatFunction","next: ExpressNextFunction","requestContext: Record<string, unknown>","requestContext","requestContext:\n | Record<string, unknown>\n | Promise<Record<string, unknown>>"],"sources":["../src/mod.ts"],"sourcesContent":["import { getLogger, type LogLevel, withContext } from \"@logtape/logtape\";\n\nexport type { LogLevel } from \"@logtape/logtape\";\n\n// Use minimal type definitions for Express compatibility across Express 4.x and 5.x\n// These are compatible with both versions and avoid strict type checking issues\n\n/**\n * Minimal Express Request interface for compatibility.\n * @since 1.3.0\n */\nexport interface ExpressRequest {\n method: string;\n url: string;\n originalUrl?: string;\n path?: string;\n httpVersion: string;\n ip?: string;\n socket?: { remoteAddress?: string };\n get(header: string): string | undefined;\n}\n\n/**\n * Minimal Express Response interface for compatibility.\n * @since 1.3.0\n */\nexport interface ExpressResponse {\n statusCode: number;\n on(event: string, listener: () => void): void;\n getHeader(name: string): string | number | string[] | undefined;\n setHeader?(name: string, value: string): void;\n}\n\n/**\n * Express NextFunction type.\n * @since 1.3.0\n */\nexport type ExpressNextFunction = (err?: unknown) => void;\n\n/**\n * Express middleware function type.\n * @since 1.3.0\n */\nexport type ExpressMiddleware = (\n req: ExpressRequest,\n res: ExpressResponse,\n next: ExpressNextFunction,\n) => void;\n\n/**\n * Predefined log format names compatible with Morgan.\n * @since 1.3.0\n */\nexport type PredefinedFormat = \"combined\" | \"common\" | \"dev\" | \"short\" | \"tiny\";\n\n/**\n * Custom format function for request logging.\n *\n * @param req The Express request object.\n * @param res The Express response object.\n * @param responseTime The response time in milliseconds.\n * @returns A string message or an object with structured properties.\n * @since 1.3.0\n */\nexport type FormatFunction = (\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n) => string | Record<string, unknown>;\n\n/**\n * Structured log properties for HTTP requests.\n * @since 1.3.0\n */\nexport interface RequestLogProperties {\n /** HTTP request method */\n method: string;\n /** Request URL */\n url: 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 */\n remoteAddr: string | undefined;\n /** User-Agent header value */\n userAgent: string | undefined;\n /** Referrer header value */\n referrer: string | undefined;\n /** HTTP version (e.g., \"1.1\") */\n httpVersion: string;\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 | \"httpVersion\";\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 req: ExpressRequest,\n res: ExpressResponse,\n ) => Record<string, unknown> | Promise<Record<string, unknown>>;\n}\n\n/**\n * Options for configuring the Express LogTape middleware.\n * @since 1.3.0\n */\nexport interface ExpressLogTapeOptions {\n /**\n * The LogTape category to use for logging.\n * @default [\"express\"]\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 successful requests\n * ```typescript\n * app.use(expressLogger({\n * skip: (req, res) => res.statusCode < 400,\n * }));\n * ```\n *\n * @default () => false\n */\n readonly skip?: (req: ExpressRequest, res: ExpressResponse) => 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 `immediate` is `true`, response-related properties\n * (status, responseTime, contentLength) will not be available.\n *\n * @default false\n */\n readonly immediate?: boolean;\n\n /**\n * Enables request-scoped implicit context and request ID correlation.\n *\n * When set to `true`, the middleware reads the `x-request-id` header,\n * generates one when it is absent, writes it to the `x-request-id` response\n * header, and adds `requestId` to all LogTape records emitted while handling\n * the 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 * 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 the request ID for a request.\n */\nfunction resolveRequestId(\n req: ExpressRequest,\n res: ExpressResponse,\n options: RequestIdOptions,\n): { property: string; value: string } {\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 = req.get(headerName);\n if (headerValue == null) continue;\n const normalized = normalize(headerValue);\n if (normalized != null) {\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n if (responseHeader !== false) res.setHeader?.(responseHeader, normalized);\n return { property, value: normalized };\n }\n }\n const generated = (options.generate ?? generateRequestId)();\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n if (responseHeader !== false) res.setHeader?.(responseHeader, generated);\n return { property, value: generated };\n}\n\n/**\n * Build request context fields from a request.\n */\nfunction buildIncludedContext(\n req: ExpressRequest,\n resolvedRequestId: { property: string; value: string } | 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 = req.method;\n break;\n case \"url\":\n context.url = req.originalUrl || req.url;\n break;\n case \"path\":\n context.path = req.path;\n break;\n case \"userAgent\":\n context.userAgent = getUserAgent(req);\n break;\n case \"remoteAddr\":\n context.remoteAddr = getRemoteAddr(req);\n break;\n case \"referrer\":\n context.referrer = getReferrer(req);\n break;\n case \"httpVersion\":\n context.httpVersion = req.httpVersion;\n break;\n }\n }\n return context;\n}\n\n/**\n * Check whether a value is a Promise object.\n */\nfunction isPromise<T>(value: unknown): value is Promise<T> {\n return value != null && typeof value === \"object\" &&\n Object.prototype.toString.call(value) === \"[object Promise]\" &&\n typeof (value as Promise<T>).then === \"function\";\n}\n\n/**\n * Build the implicit context for a request.\n */\nfunction buildRequestContext(\n req: ExpressRequest,\n res: ExpressResponse,\n options: RequestContextOptions,\n): Record<string, unknown> | Promise<Record<string, unknown>> {\n const requestIdOptions = normalizeRequestIdOptions(options.requestId);\n const resolvedRequestId = requestIdOptions == null\n ? undefined\n : resolveRequestId(req, res, requestIdOptions);\n const include = options.include ??\n (resolvedRequestId == null ? [] : [\"requestId\"] as const);\n const context = buildIncludedContext(req, resolvedRequestId, include);\n if (options.enrich == null) return context;\n const enriched = options.enrich(req, res);\n if (isPromise<Record<string, unknown>>(enriched)) {\n return Promise.resolve(enriched).then((extraContext) => ({\n ...context,\n ...extraContext,\n }));\n }\n return { ...context, ...enriched };\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 * Get remote address from request.\n */\nfunction getRemoteAddr(req: ExpressRequest): string | undefined {\n return req.ip || req.socket?.remoteAddress;\n}\n\n/**\n * Get content length from response headers.\n */\nfunction getContentLength(res: ExpressResponse): string | undefined {\n const contentLength = res.getHeader(\"content-length\");\n if (contentLength === undefined || contentLength === null) return undefined;\n return String(contentLength);\n}\n\n/**\n * Get referrer from request headers.\n */\nfunction getReferrer(req: ExpressRequest): string | undefined {\n return req.get(\"referrer\") || req.get(\"referer\");\n}\n\n/**\n * Get user agent from request headers.\n */\nfunction getUserAgent(req: ExpressRequest): string | undefined {\n return req.get(\"user-agent\");\n}\n\n/**\n * Build structured log properties from request/response.\n */\nfunction buildProperties(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): RequestLogProperties {\n return {\n method: req.method,\n url: req.originalUrl || req.url,\n status: res.statusCode,\n responseTime,\n contentLength: getContentLength(res),\n remoteAddr: getRemoteAddr(req),\n userAgent: getUserAgent(req),\n referrer: getReferrer(req),\n httpVersion: req.httpVersion,\n };\n}\n\n/**\n * Combined format (Apache Combined Log Format).\n * Returns all structured properties.\n */\nfunction formatCombined(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): Record<string, unknown> {\n return { ...buildProperties(req, res, responseTime) };\n}\n\n/**\n * Common format (Apache Common Log Format).\n * Like combined but without referrer and userAgent.\n */\nfunction formatCommon(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): Record<string, unknown> {\n const props = buildProperties(req, res, responseTime);\n const { referrer: _referrer, userAgent: _userAgent, ...rest } = props;\n return rest;\n}\n\n/**\n * Dev format (colored output for development).\n * :method :url :status :response-time ms - :res[content-length]\n */\nfunction formatDev(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): string {\n const contentLength = getContentLength(res) ?? \"-\";\n return `${req.method} ${req.originalUrl || req.url} ${res.statusCode} ${\n responseTime.toFixed(3)\n } ms - ${contentLength}`;\n}\n\n/**\n * Short format.\n * :remote-addr :method :url HTTP/:http-version :status :res[content-length] - :response-time ms\n */\nfunction formatShort(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): string {\n const remoteAddr = getRemoteAddr(req) ?? \"-\";\n const contentLength = getContentLength(res) ?? \"-\";\n return `${remoteAddr} ${req.method} ${\n req.originalUrl || req.url\n } HTTP/${req.httpVersion} ${res.statusCode} ${contentLength} - ${\n responseTime.toFixed(3)\n } ms`;\n}\n\n/**\n * Tiny format (minimal output).\n * :method :url :status :res[content-length] - :response-time ms\n */\nfunction formatTiny(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): string {\n const contentLength = getContentLength(res) ?? \"-\";\n return `${req.method} ${\n req.originalUrl || req.url\n } ${res.statusCode} ${contentLength} - ${responseTime.toFixed(3)} 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 * Creates Express middleware for HTTP request logging using LogTape.\n *\n * This middleware 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 express from \"express\";\n * import { configure, getConsoleSink } from \"@logtape/logtape\";\n * import { expressLogger } from \"@logtape/express\";\n *\n * await configure({\n * sinks: { console: getConsoleSink() },\n * loggers: [\n * { category: [\"express\"], sinks: [\"console\"], lowestLevel: \"info\" }\n * ],\n * });\n *\n * const app = express();\n * app.use(expressLogger());\n *\n * app.get(\"/\", (req, res) => {\n * res.json({ hello: \"world\" });\n * });\n *\n * app.listen(3000);\n * ```\n *\n * @example With custom options\n * ```typescript\n * app.use(expressLogger({\n * category: [\"myapp\", \"http\"],\n * level: \"debug\",\n * format: \"dev\",\n * skip: (req, res) => res.statusCode < 400,\n * }));\n * ```\n *\n * @example With custom format function\n * ```typescript\n * app.use(expressLogger({\n * format: (req, res, responseTime) => ({\n * method: req.method,\n * path: req.path,\n * status: res.statusCode,\n * duration: responseTime,\n * }),\n * }));\n * ```\n *\n * @param options Configuration options for the middleware.\n * @returns Express middleware function.\n * @since 1.3.0\n */\nexport function expressLogger(\n options: ExpressLogTapeOptions = {},\n): ExpressMiddleware {\n const category = normalizeCategory(options.category ?? [\"express\"]);\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 immediate = options.immediate ?? false;\n const contextOptions = normalizeRequestContextOptions(options.context);\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\n return (\n req: ExpressRequest,\n res: ExpressResponse,\n next: ExpressNextFunction,\n ): void => {\n const startTime = Date.now();\n\n const handleRequest = (requestContext: Record<string, unknown>): void => {\n // For immediate logging, log when request arrives\n if (immediate) {\n if (!skip(req, res)) {\n const result = withRequestLogContext(\n formatFn(req, res, 0),\n requestContext,\n );\n if (typeof result === \"string\") {\n logMethod(result, requestContext);\n } else {\n logMethod(\"{method} {url}\", result);\n }\n }\n next();\n return;\n }\n\n // Log after response is sent\n const logRequest = (): void => {\n if (skip(req, res)) return;\n\n const responseTime = Date.now() - startTime;\n const result = withRequestLogContext(\n formatFn(req, res, 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 // Listen for response finish event\n res.on(\"finish\", logRequest);\n\n next();\n };\n\n if (contextOptions == null) {\n handleRequest({});\n return;\n }\n\n let requestContext:\n | Record<string, unknown>\n | Promise<Record<string, unknown>>;\n try {\n requestContext = buildRequestContext(req, res, contextOptions);\n } catch (error) {\n next(error);\n return;\n }\n if (isPromise<Record<string, unknown>>(requestContext)) {\n Promise.resolve(requestContext)\n .then((resolvedContext) => {\n withContext(resolvedContext, () => handleRequest(resolvedContext));\n })\n .catch(next);\n return;\n }\n\n withContext(requestContext, () => handleRequest(requestContext));\n };\n}\n"],"mappings":";;;AAoPA,MAAM,yBAAyB;;;;AAK/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,YAAY;AAEvC,SAAQ,EAAE,KAAK,KAAK,CAAC,SAAS,GAAG,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;AAC1E;;;;AAKD,SAAS,0BAA0BC,OAA8B;CAC/D,MAAM,UAAU,MAAM,MAAM;AAC5B,QAAO,YAAY,KAAK,OAAO;AAChC;;;;AAKD,SAAS,iBACPC,KACAC,KACAC,SACqC;CACrC,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,cAAc,QAAQ,eAAe,CAAC,sBAAuB;AACnE,MAAK,MAAM,cAAc,aAAa;EACpC,MAAM,cAAc,IAAI,IAAI,WAAW;AACvC,MAAI,eAAe,KAAM;EACzB,MAAM,aAAa,UAAU,YAAY;AACzC,MAAI,cAAc,MAAM;GACtB,MAAMC,mBAAiB,QAAQ,kBAAkB;AACjD,OAAIA,qBAAmB,MAAO,KAAI,YAAYA,kBAAgB,WAAW;AACzE,UAAO;IAAE;IAAU,OAAO;GAAY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KAAK,OAAO;AAE5C,QAAO,CACLd,KACAC,KACAc,SACS;EACT,MAAM,YAAY,KAAK,KAAK;EAE5B,MAAM,gBAAgB,CAACC,qBAAkD;AAEvE,OAAI,WAAW;AACb,SAAK,KAAK,KAAK,IAAI,EAAE;KACnB,MAAM,SAAS,sBACb,SAAS,KAAK,KAAK,EAAE,EACrBC,iBACD;AACD,gBAAW,WAAW,SACpB,WAAU,QAAQA,iBAAe;SAEjC,WAAU,kBAAkB,OAAO;IAEtC;AACD,UAAM;AACN;GACD;GAGD,MAAM,aAAa,MAAY;AAC7B,QAAI,KAAK,KAAK,IAAI,CAAE;IAEpB,MAAM,eAAe,KAAK,KAAK,GAAG;IAClC,MAAM,SAAS,sBACb,SAAS,KAAK,KAAK,aAAa,EAChCA,iBACD;AAED,eAAW,WAAW,SACpB,WAAU,QAAQA,iBAAe;QAEjC,WAAU,+CAA+C,OAAO;GAEnE;AAGD,OAAI,GAAG,UAAU,WAAW;AAE5B,SAAM;EACP;AAED,MAAI,kBAAkB,MAAM;AAC1B,iBAAc,CAAE,EAAC;AACjB;EACD;EAED,IAAIC;AAGJ,MAAI;AACF,oBAAiB,oBAAoB,KAAK,KAAK,eAAe;EAC/D,SAAQ,OAAO;AACd,QAAK,MAAM;AACX;EACD;AACD,MAAI,UAAmC,eAAe,EAAE;AACtD,WAAQ,QAAQ,eAAe,CAC5B,KAAK,CAAC,oBAAoB;AACzB,gBAAY,iBAAiB,MAAM,cAAc,gBAAgB,CAAC;GACnE,EAAC,CACD,MAAM,KAAK;AACd;EACD;AAED,cAAY,gBAAgB,MAAM,cAAc,eAAe,CAAC;CACjE;AACF"}
1
+ {"version":3,"file":"mod.js","names":["options: boolean | RequestContextOptions | undefined","options: boolean | RequestIdOptions | undefined","value: string","req: ExpressRequest","res: ExpressResponse","options: RequestIdOptions","responseHeader","resolvedRequestId: { property: string; value: string } | undefined","include: readonly RequestContextField[]","context: Record<string, unknown>","value: unknown","options: RequestContextOptions","result: string | Record<string, unknown>","value: number","timestamp: number","escapeSpaces: boolean","responseTime: number","predefinedFormats: Record<PredefinedFormat, FormatFunction>","category: string | readonly string[]","options: ExpressLogTapeOptions","formatFn: FormatFunction","next: ExpressNextFunction","requestContext: Record<string, unknown>","requestContext","requestContext:\n | Record<string, unknown>\n | Promise<Record<string, unknown>>"],"sources":["../src/mod.ts"],"sourcesContent":["import { getLogger, type LogLevel, withContext } from \"@logtape/logtape\";\n\nexport type { LogLevel } from \"@logtape/logtape\";\n\n// Use minimal type definitions for Express compatibility across Express 4.x and 5.x\n// These are compatible with both versions and avoid strict type checking issues\n\n/**\n * Minimal Express Request interface for compatibility.\n * @since 1.3.0\n */\nexport interface ExpressRequest {\n method: string;\n url: string;\n originalUrl?: string;\n path?: string;\n httpVersion: string;\n ip?: string;\n socket?: { remoteAddress?: string };\n get(header: string): string | undefined;\n}\n\n/**\n * Minimal Express Response interface for compatibility.\n * @since 1.3.0\n */\nexport interface ExpressResponse {\n statusCode: number;\n on(event: string, listener: () => void): void;\n getHeader(name: string): string | number | string[] | undefined;\n setHeader?(name: string, value: string): void;\n}\n\n/**\n * Express NextFunction type.\n * @since 1.3.0\n */\nexport type ExpressNextFunction = (err?: unknown) => void;\n\n/**\n * Express middleware function type.\n * @since 1.3.0\n */\nexport type ExpressMiddleware = (\n req: ExpressRequest,\n res: ExpressResponse,\n next: ExpressNextFunction,\n) => void;\n\n/**\n * Predefined log format names.\n * @since 1.3.0\n */\nexport type PredefinedFormat =\n /**\n * @deprecated Use `\"structured-combined\"` instead.\n */\n | \"combined\"\n /**\n * @deprecated Use `\"structured-common\"` instead.\n */\n | \"common\"\n | \"structured-combined\"\n | \"structured-common\"\n | \"morgan-combined\"\n | \"morgan-common\"\n | \"dev\"\n | \"short\"\n | \"tiny\";\n\n/**\n * Custom format function for request logging.\n *\n * @param req The Express request object.\n * @param res The Express response object.\n * @param responseTime The response time in milliseconds.\n * @returns A string message or an object with structured properties.\n * @since 1.3.0\n */\nexport type FormatFunction = (\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n) => string | Record<string, unknown>;\n\n/**\n * Structured log properties for HTTP requests.\n * @since 1.3.0\n */\nexport interface RequestLogProperties {\n /** HTTP request method */\n method: string;\n /** Request URL */\n url: 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 */\n remoteAddr: string | undefined;\n /** User-Agent header value */\n userAgent: string | undefined;\n /** Referrer header value */\n referrer: string | undefined;\n /** HTTP version (e.g., \"1.1\") */\n httpVersion: string;\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 | \"httpVersion\";\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 req: ExpressRequest,\n res: ExpressResponse,\n ) => Record<string, unknown> | Promise<Record<string, unknown>>;\n}\n\n/**\n * Options for configuring the Express LogTape middleware.\n * @since 1.3.0\n */\nexport interface ExpressLogTapeOptions {\n /**\n * The LogTape category to use for logging.\n * @default [\"express\"]\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 * Structured formats:\n * - `\"structured-combined\"` - All structured request properties (default)\n * - `\"structured-common\"` - Structured request properties without\n * referrer/userAgent\n * - `\"combined\"` - Deprecated alias for `\"structured-combined\"`\n * - `\"common\"` - Deprecated alias for `\"structured-common\"`\n *\n * Text formats:\n * - `\"morgan-combined\"` - Morgan-compatible combined access log (string)\n * - `\"morgan-common\"` - Morgan-compatible common access log (string)\n * - `\"dev\"` - Concise colored output for development (string)\n * - `\"short\"` - Shorter than common (string)\n * - `\"tiny\"` - Minimal output (string)\n *\n * @default \"structured-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 successful requests\n * ```typescript\n * app.use(expressLogger({\n * skip: (req, res) => res.statusCode < 400,\n * }));\n * ```\n *\n * @default () => false\n */\n readonly skip?: (req: ExpressRequest, res: ExpressResponse) => 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 `immediate` is `true`, response-related properties\n * (status, responseTime, contentLength) will not be available.\n *\n * @default false\n */\n readonly immediate?: boolean;\n\n /**\n * Enables request-scoped implicit context and request ID correlation.\n *\n * When set to `true`, the middleware reads the `x-request-id` header,\n * generates one when it is absent, writes it to the `x-request-id` response\n * header, and adds `requestId` to all LogTape records emitted while handling\n * the 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 * 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 the request ID for a request.\n */\nfunction resolveRequestId(\n req: ExpressRequest,\n res: ExpressResponse,\n options: RequestIdOptions,\n): { property: string; value: string } {\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 = req.get(headerName);\n if (headerValue == null) continue;\n const normalized = normalize(headerValue);\n if (normalized != null) {\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n if (responseHeader !== false) res.setHeader?.(responseHeader, normalized);\n return { property, value: normalized };\n }\n }\n const generated = (options.generate ?? generateRequestId)();\n const responseHeader = options.responseHeader ?? defaultRequestIdHeader;\n if (responseHeader !== false) res.setHeader?.(responseHeader, generated);\n return { property, value: generated };\n}\n\n/**\n * Build request context fields from a request.\n */\nfunction buildIncludedContext(\n req: ExpressRequest,\n resolvedRequestId: { property: string; value: string } | 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 = req.method;\n break;\n case \"url\":\n context.url = req.originalUrl || req.url;\n break;\n case \"path\":\n context.path = req.path;\n break;\n case \"userAgent\":\n context.userAgent = getUserAgent(req);\n break;\n case \"remoteAddr\":\n context.remoteAddr = getRemoteAddr(req);\n break;\n case \"referrer\":\n context.referrer = getReferrer(req);\n break;\n case \"httpVersion\":\n context.httpVersion = req.httpVersion;\n break;\n }\n }\n return context;\n}\n\n/**\n * Check whether a value is a Promise object.\n */\nfunction isPromise<T>(value: unknown): value is Promise<T> {\n return value != null && typeof value === \"object\" &&\n Object.prototype.toString.call(value) === \"[object Promise]\" &&\n typeof (value as Promise<T>).then === \"function\";\n}\n\n/**\n * Build the implicit context for a request.\n */\nfunction buildRequestContext(\n req: ExpressRequest,\n res: ExpressResponse,\n options: RequestContextOptions,\n): Record<string, unknown> | Promise<Record<string, unknown>> {\n const requestIdOptions = normalizeRequestIdOptions(options.requestId);\n const resolvedRequestId = requestIdOptions == null\n ? undefined\n : resolveRequestId(req, res, requestIdOptions);\n const include = options.include ??\n (resolvedRequestId == null ? [] : [\"requestId\"] as const);\n const context = buildIncludedContext(req, resolvedRequestId, include);\n if (options.enrich == null) return context;\n const enriched = options.enrich(req, res);\n if (isPromise<Record<string, unknown>>(enriched)) {\n return Promise.resolve(enriched).then((extraContext) => ({\n ...context,\n ...extraContext,\n }));\n }\n return { ...context, ...enriched };\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\nconst clfMonths = [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n] as const;\n\nfunction pad2(value: number): string {\n return value.toString().padStart(2, \"0\");\n}\n\nfunction formatClfDate(timestamp: number = Date.now()): string {\n const date = new Date(timestamp);\n return `${pad2(date.getUTCDate())}/${\n clfMonths[date.getUTCMonth()]\n }/${date.getUTCFullYear()}:${pad2(date.getUTCHours())}:${\n pad2(date.getUTCMinutes())\n }:${pad2(date.getUTCSeconds())} +0000`;\n}\n\nfunction escapeAccessLogValue(value: unknown, escapeSpaces: boolean): string {\n const escaped = String(value)\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\t/g, \"\\\\t\");\n return escapeSpaces ? escaped.replace(/ /g, \"\\\\x20\") : escaped;\n}\n\nfunction formatAccessLogToken(value: unknown): string {\n if (value == null || value === \"\") return \"-\";\n return escapeAccessLogValue(value, true);\n}\n\nfunction formatAccessLogQuotedToken(value: unknown): string {\n if (value == null || value === \"\") return '\"-\"';\n return `\"${escapeAccessLogValue(value, false)}\"`;\n}\n\nfunction getRemoteUser(req: ExpressRequest): string | undefined {\n const authorization = req.get(\"authorization\");\n if (authorization == null) return undefined;\n const match = /^Basic\\s+(.+)$/i.exec(authorization);\n if (match == null || typeof globalThis.atob !== \"function\") {\n return undefined;\n }\n try {\n const decoded = globalThis.atob(match[1]);\n const colonIndex = decoded.indexOf(\":\");\n const user = colonIndex < 0 ? decoded : decoded.slice(0, colonIndex);\n return user === \"\" ? undefined : user;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Get remote address from request.\n */\nfunction getRemoteAddr(req: ExpressRequest): string | undefined {\n return req.ip || req.socket?.remoteAddress;\n}\n\n/**\n * Get content length from response headers.\n */\nfunction getContentLength(res: ExpressResponse): string | undefined {\n const contentLength = res.getHeader(\"content-length\");\n if (contentLength === undefined || contentLength === null) return undefined;\n return String(contentLength);\n}\n\n/**\n * Get referrer from request headers.\n */\nfunction getReferrer(req: ExpressRequest): string | undefined {\n return req.get(\"referrer\") || req.get(\"referer\");\n}\n\n/**\n * Get user agent from request headers.\n */\nfunction getUserAgent(req: ExpressRequest): string | undefined {\n return req.get(\"user-agent\");\n}\n\n/**\n * Build structured log properties from request/response.\n */\nfunction buildProperties(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): RequestLogProperties {\n return {\n method: req.method,\n url: req.originalUrl || req.url,\n status: res.statusCode,\n responseTime,\n contentLength: getContentLength(res),\n remoteAddr: getRemoteAddr(req),\n userAgent: getUserAgent(req),\n referrer: getReferrer(req),\n httpVersion: req.httpVersion,\n };\n}\n\n/**\n * Structured combined format.\n * Returns all structured properties.\n */\nfunction formatCombined(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): Record<string, unknown> {\n return { ...buildProperties(req, res, responseTime) };\n}\n\n/**\n * Structured common format.\n * Like structured combined but without referrer and userAgent.\n */\nfunction formatCommon(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): Record<string, unknown> {\n const props = buildProperties(req, res, responseTime);\n const { referrer: _referrer, userAgent: _userAgent, ...rest } = props;\n return rest;\n}\n\n/**\n * Morgan combined format.\n * :remote-addr - :remote-user [:date[clf]]\n * \":method :url HTTP/:http-version\" :status :res[content-length]\n * \":referrer\" \":user-agent\"\n */\nfunction formatMorganCombined(\n req: ExpressRequest,\n res: ExpressResponse,\n): string {\n return `${formatAccessLogToken(getRemoteAddr(req))} - ${\n formatAccessLogToken(getRemoteUser(req))\n } [${formatClfDate()}] \"${formatAccessLogToken(req.method)} ${\n formatAccessLogToken(req.originalUrl || req.url)\n } HTTP/${formatAccessLogToken(req.httpVersion)}\" ${\n formatAccessLogToken(res.statusCode)\n } ${formatAccessLogToken(getContentLength(res))} ${\n formatAccessLogQuotedToken(getReferrer(req))\n } ${formatAccessLogQuotedToken(getUserAgent(req))}`;\n}\n\n/**\n * Morgan common format.\n * :remote-addr - :remote-user [:date[clf]]\n * \":method :url HTTP/:http-version\" :status :res[content-length]\n */\nfunction formatMorganCommon(\n req: ExpressRequest,\n res: ExpressResponse,\n): string {\n return `${formatAccessLogToken(getRemoteAddr(req))} - ${\n formatAccessLogToken(getRemoteUser(req))\n } [${formatClfDate()}] \"${formatAccessLogToken(req.method)} ${\n formatAccessLogToken(req.originalUrl || req.url)\n } HTTP/${formatAccessLogToken(req.httpVersion)}\" ${\n formatAccessLogToken(res.statusCode)\n } ${formatAccessLogToken(getContentLength(res))}`;\n}\n\n/**\n * Dev format (colored output for development).\n * :method :url :status :response-time ms - :res[content-length]\n */\nfunction formatDev(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): string {\n const contentLength = getContentLength(res) ?? \"-\";\n return `${req.method} ${req.originalUrl || req.url} ${res.statusCode} ${\n responseTime.toFixed(3)\n } ms - ${contentLength}`;\n}\n\n/**\n * Short format.\n * :remote-addr :method :url HTTP/:http-version :status :res[content-length] - :response-time ms\n */\nfunction formatShort(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): string {\n const remoteAddr = getRemoteAddr(req) ?? \"-\";\n const contentLength = getContentLength(res) ?? \"-\";\n return `${remoteAddr} ${req.method} ${\n req.originalUrl || req.url\n } HTTP/${req.httpVersion} ${res.statusCode} ${contentLength} - ${\n responseTime.toFixed(3)\n } ms`;\n}\n\n/**\n * Tiny format (minimal output).\n * :method :url :status :res[content-length] - :response-time ms\n */\nfunction formatTiny(\n req: ExpressRequest,\n res: ExpressResponse,\n responseTime: number,\n): string {\n const contentLength = getContentLength(res) ?? \"-\";\n return `${req.method} ${\n req.originalUrl || req.url\n } ${res.statusCode} ${contentLength} - ${responseTime.toFixed(3)} ms`;\n}\n\n/**\n * Map of predefined format functions.\n */\nconst predefinedFormats: Record<PredefinedFormat, FormatFunction> = {\n combined: formatCombined,\n common: formatCommon,\n \"structured-combined\": formatCombined,\n \"structured-common\": formatCommon,\n \"morgan-combined\": formatMorganCombined,\n \"morgan-common\": formatMorganCommon,\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 * Creates Express middleware for HTTP request logging using LogTape.\n *\n * This middleware 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 express from \"express\";\n * import { configure, getConsoleSink } from \"@logtape/logtape\";\n * import { expressLogger } from \"@logtape/express\";\n *\n * await configure({\n * sinks: { console: getConsoleSink() },\n * loggers: [\n * { category: [\"express\"], sinks: [\"console\"], lowestLevel: \"info\" }\n * ],\n * });\n *\n * const app = express();\n * app.use(expressLogger());\n *\n * app.get(\"/\", (req, res) => {\n * res.json({ hello: \"world\" });\n * });\n *\n * app.listen(3000);\n * ```\n *\n * @example With custom options\n * ```typescript\n * app.use(expressLogger({\n * category: [\"myapp\", \"http\"],\n * level: \"debug\",\n * format: \"dev\",\n * skip: (req, res) => res.statusCode < 400,\n * }));\n * ```\n *\n * @example With custom format function\n * ```typescript\n * app.use(expressLogger({\n * format: (req, res, responseTime) => ({\n * method: req.method,\n * path: req.path,\n * status: res.statusCode,\n * duration: responseTime,\n * }),\n * }));\n * ```\n *\n * @param options Configuration options for the middleware.\n * @returns Express middleware function.\n * @since 1.3.0\n */\nexport function expressLogger(\n options: ExpressLogTapeOptions = {},\n): ExpressMiddleware {\n const category = normalizeCategory(options.category ?? [\"express\"]);\n const logger = getLogger(category);\n const level = options.level ?? \"info\";\n const formatOption = options.format ?? \"structured-combined\";\n const skip = options.skip ?? (() => false);\n const immediate = options.immediate ?? false;\n const contextOptions = normalizeRequestContextOptions(options.context);\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\n return (\n req: ExpressRequest,\n res: ExpressResponse,\n next: ExpressNextFunction,\n ): void => {\n const startTime = Date.now();\n\n const handleRequest = (requestContext: Record<string, unknown>): void => {\n // For immediate logging, log when request arrives\n if (immediate) {\n if (!skip(req, res)) {\n const result = withRequestLogContext(\n formatFn(req, res, 0),\n requestContext,\n );\n if (typeof result === \"string\") {\n logMethod(result, requestContext);\n } else {\n logMethod(\"{method} {url}\", result);\n }\n }\n next();\n return;\n }\n\n // Log after response is sent\n const logRequest = (): void => {\n if (skip(req, res)) return;\n\n const responseTime = Date.now() - startTime;\n const result = withRequestLogContext(\n formatFn(req, res, 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 // Listen for response finish event\n res.on(\"finish\", logRequest);\n\n next();\n };\n\n if (contextOptions == null) {\n handleRequest({});\n return;\n }\n\n let requestContext:\n | Record<string, unknown>\n | Promise<Record<string, unknown>>;\n try {\n requestContext = buildRequestContext(req, res, contextOptions);\n } catch (error) {\n next(error);\n return;\n }\n if (isPromise<Record<string, unknown>>(requestContext)) {\n Promise.resolve(requestContext)\n .then((resolvedContext) => {\n withContext(resolvedContext, () => handleRequest(resolvedContext));\n })\n .catch(next);\n return;\n }\n\n withContext(requestContext, () => handleRequest(requestContext));\n };\n}\n"],"mappings":";;;AA0QA,MAAM,yBAAyB;;;;AAK/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,YAAY;AAEvC,SAAQ,EAAE,KAAK,KAAK,CAAC,SAAS,GAAG,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;AAC1E;;;;AAKD,SAAS,0B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
1
1
  {
2
2
  "name": "@logtape/express",
3
- "version": "2.2.0-dev.766+d7c798d3",
3
+ "version": "2.2.0-dev.767+7533e10c",
4
4
  "description": "Express adapter for LogTape logging library",
5
5
  "keywords": [
6
6
  "logging",
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "peerDependencies": {
55
55
  "express": "^4.0.0 || ^5.0.0",
56
- "@logtape/logtape": "^2.2.0-dev.766+d7c798d3"
56
+ "@logtape/logtape": "^2.2.0-dev.767+7533e10c"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@alinea/suite": "^0.6.3",