@emmett-community/emmett-expressjs-with-openapi 0.5.0 → 0.7.0
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/{chunk-FSPH5TRT.cjs → chunk-HX5NHAJY.cjs} +14 -2
- package/dist/chunk-HX5NHAJY.cjs.map +1 -0
- package/dist/{chunk-PZBLPYJH.js → chunk-P6WGW2FK.js} +14 -2
- package/dist/{chunk-PZBLPYJH.js.map → chunk-P6WGW2FK.js.map} +1 -1
- package/dist/handler-importer-F73SZ2KQ.cjs +77 -0
- package/dist/handler-importer-F73SZ2KQ.cjs.map +1 -0
- package/dist/{handler-importer-V4EJZ2DG.js → handler-importer-SE6HRBDZ.js} +35 -4
- package/dist/handler-importer-SE6HRBDZ.js.map +1 -0
- package/dist/index.cjs +15 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/{openapi-parser-SFYDJEIN.js → openapi-parser-CVIKTGAQ.js} +2 -2
- package/dist/{openapi-parser-HMWO3IPV.cjs → openapi-parser-G4KTMZEZ.cjs} +6 -6
- package/dist/{openapi-parser-HMWO3IPV.cjs.map → openapi-parser-G4KTMZEZ.cjs.map} +1 -1
- package/package.json +3 -6
- package/dist/chunk-FSPH5TRT.cjs.map +0 -1
- package/dist/handler-importer-BRJVJNST.cjs +0 -46
- package/dist/handler-importer-BRJVJNST.cjs.map +0 -1
- package/dist/handler-importer-V4EJZ2DG.js.map +0 -1
- /package/dist/{openapi-parser-SFYDJEIN.js.map → openapi-parser-CVIKTGAQ.js.map} +0 -0
|
@@ -10,7 +10,7 @@ var safeLog = {
|
|
|
10
10
|
},
|
|
11
11
|
warn: (logger, msg, data) => {
|
|
12
12
|
if (!logger) return;
|
|
13
|
-
logger.warn(
|
|
13
|
+
logger.warn(normalizeWarnContext(data), msg);
|
|
14
14
|
},
|
|
15
15
|
error: (logger, msg, error) => {
|
|
16
16
|
if (!logger) return;
|
|
@@ -26,6 +26,18 @@ function normalizeContext(data) {
|
|
|
26
26
|
}
|
|
27
27
|
return { data };
|
|
28
28
|
}
|
|
29
|
+
function normalizeWarnContext(data) {
|
|
30
|
+
if (data === void 0 || data === null) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
if (data instanceof Error) {
|
|
34
|
+
return { err: data };
|
|
35
|
+
}
|
|
36
|
+
if (typeof data === "object" && !Array.isArray(data)) {
|
|
37
|
+
return { ...data };
|
|
38
|
+
}
|
|
39
|
+
return { data };
|
|
40
|
+
}
|
|
29
41
|
function normalizeErrorContext(error) {
|
|
30
42
|
if (error === void 0 || error === null) {
|
|
31
43
|
return {};
|
|
@@ -42,4 +54,4 @@ function normalizeErrorContext(error) {
|
|
|
42
54
|
|
|
43
55
|
|
|
44
56
|
exports.safeLog = safeLog;
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-HX5NHAJY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/emmett-expressjs-with-openapi/emmett-expressjs-with-openapi/dist/chunk-HX5NHAJY.cjs","../src/observability.ts"],"names":[],"mappings":"AAAA;AC+FO,IAAM,QAAA,EAAU;AAAA,EACrB,KAAA,EAAO,CAAC,MAAA,EAA4B,GAAA,EAAa,IAAA,EAAA,GAAmB;AAClE,IAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,MAAA;AACb,IAAA,MAAA,CAAO,KAAA,CAAM,gBAAA,CAAiB,IAAI,CAAA,EAAG,GAAG,CAAA;AAAA,EAC1C,CAAA;AAAA,EACA,IAAA,EAAM,CAAC,MAAA,EAA4B,GAAA,EAAa,IAAA,EAAA,GAAmB;AACjE,IAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,MAAA;AACb,IAAA,MAAA,CAAO,IAAA,CAAK,gBAAA,CAAiB,IAAI,CAAA,EAAG,GAAG,CAAA;AAAA,EACzC,CAAA;AAAA,EACA,IAAA,EAAM,CAAC,MAAA,EAA4B,GAAA,EAAa,IAAA,EAAA,GAAmB;AACjE,IAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,MAAA;AACb,IAAA,MAAA,CAAO,IAAA,CAAK,oBAAA,CAAqB,IAAI,CAAA,EAAG,GAAG,CAAA;AAAA,EAC7C,CAAA;AAAA,EACA,KAAA,EAAO,CAAC,MAAA,EAA4B,GAAA,EAAa,KAAA,EAAA,GAAoB;AACnE,IAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,MAAA;AACb,IAAA,MAAA,CAAO,KAAA,CAAM,qBAAA,CAAsB,KAAK,CAAA,EAAG,GAAG,CAAA;AAAA,EAChD;AACF,CAAA;AAMA,SAAS,gBAAA,CAAiB,IAAA,EAAwC;AAChE,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,IAAA,EAAM;AACvC,IAAA,OAAO,CAAC,CAAA;AAAA,EACV;AACA,EAAA,GAAA,CAAI,OAAO,KAAA,IAAS,SAAA,GAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AACpD,IAAA,OAAO,EAAE,GAAI,KAAiC,CAAA;AAAA,EAChD;AACA,EAAA,OAAO,EAAE,KAAK,CAAA;AAChB;AAOA,SAAS,oBAAA,CAAqB,IAAA,EAAwC;AACpE,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,IAAA,EAAM;AACvC,IAAA,OAAO,CAAC,CAAA;AAAA,EACV;AACA,EAAA,GAAA,CAAI,KAAA,WAAgB,KAAA,EAAO;AACzB,IAAA,OAAO,EAAE,GAAA,EAAK,KAAK,CAAA;AAAA,EACrB;AACA,EAAA,GAAA,CAAI,OAAO,KAAA,IAAS,SAAA,GAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AACpD,IAAA,OAAO,EAAE,GAAI,KAAiC,CAAA;AAAA,EAChD;AACA,EAAA,OAAO,EAAE,KAAK,CAAA;AAChB;AAOA,SAAS,qBAAA,CAAsB,KAAA,EAAyC;AACtE,EAAA,GAAA,CAAI,MAAA,IAAU,KAAA,EAAA,GAAa,MAAA,IAAU,IAAA,EAAM;AACzC,IAAA,OAAO,CAAC,CAAA;AAAA,EACV;AACA,EAAA,GAAA,CAAI,MAAA,WAAiB,KAAA,EAAO;AAC1B,IAAA,OAAO,EAAE,GAAA,EAAK,MAAM,CAAA;AAAA,EACtB;AACA,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACtD,IAAA,OAAO,EAAE,GAAI,MAAkC,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,EAAE,GAAA,EAAK,MAAM,CAAA;AACtB;AD9GA;AACA;AACE;AACF,0BAAC","file":"/home/runner/work/emmett-expressjs-with-openapi/emmett-expressjs-with-openapi/dist/chunk-HX5NHAJY.cjs","sourcesContent":[null,"/**\n * Observability types for emmett-expressjs-with-openapi.\n *\n * This module provides optional logging integration\n * following a \"silent by default\" philosophy.\n */\n\n/**\n * Canonical Logger contract for the Emmett ecosystem.\n *\n * This package defines the canonical Logger interface.\n * Implementations (Pino, Winston, etc.) MUST adapt to this contract.\n * This contract MUST NOT adapt to any specific implementation.\n *\n * Semantic Rules:\n * - context (first parameter): ALWAYS structured data as Record<string, unknown>\n * - message (second parameter): ALWAYS the human-readable log message\n * - The order is NEVER inverted\n * - The (message, data) form is NOT valid for this contract\n *\n * @example\n * ```typescript\n * // Pino - native compatibility\n * import pino from 'pino';\n * const logger = pino();\n * // logger.info({ orderId }, 'Order created') matches our contract\n * ```\n */\nexport interface Logger {\n /**\n * Log debug-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n debug(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log info-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n info(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log warn-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n warn(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log error-level message with structured context.\n * @param context - Structured data to include in the log entry (may include 'err' key)\n * @param message - Optional human-readable message\n */\n error(context: Record<string, unknown>, message?: string): void;\n}\n\n/**\n * Observability configuration options.\n */\nexport type ObservabilityOptions = {\n /**\n * Optional logger instance for diagnostic output.\n * When not provided, the library operates silently.\n *\n * @example\n * ```typescript\n * import pino from 'pino';\n *\n * const logger = pino();\n *\n * const app = await getApplication({\n * observability: { logger },\n * });\n * ```\n */\n logger?: Logger;\n};\n\n/**\n * Internal helper to safely call logger methods.\n *\n * IMPORTANT: safeLog is the ONLY translation point between internal usage\n * and the Logger contract.\n *\n * Internal Usage Pattern:\n * safeLog.info(logger, 'Order created', { orderId: 123 })\n *\n * Translation to Logger Contract:\n * logger.info({ orderId: 123 }, 'Order created')\n *\n * This allows ergonomic internal usage while ensuring all injected loggers\n * receive calls in the canonical (context, message) format.\n */\nexport const safeLog = {\n debug: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.debug(normalizeContext(data), msg);\n },\n info: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.info(normalizeContext(data), msg);\n },\n warn: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.warn(normalizeWarnContext(data), msg);\n },\n error: (logger: Logger | undefined, msg: string, error?: unknown) => {\n if (!logger) return;\n logger.error(normalizeErrorContext(error), msg);\n },\n};\n\n/**\n * Normalize data to context object for regular log methods.\n * Creates a shallow copy to avoid accidental mutation of the original object.\n */\nfunction normalizeContext(data: unknown): Record<string, unknown> {\n if (data === undefined || data === null) {\n return {};\n }\n if (typeof data === 'object' && !Array.isArray(data)) {\n return { ...(data as Record<string, unknown>) };\n }\n return { data };\n}\n\n/**\n * Normalize data to context object for warn log method.\n * Uses 'err' key for Error instances to prevent property leakage (like 'name' overwriting logger name).\n * Creates a shallow copy to avoid accidental mutation of the original object.\n */\nfunction normalizeWarnContext(data: unknown): Record<string, unknown> {\n if (data === undefined || data === null) {\n return {};\n }\n if (data instanceof Error) {\n return { err: data };\n }\n if (typeof data === 'object' && !Array.isArray(data)) {\n return { ...(data as Record<string, unknown>) };\n }\n return { data };\n}\n\n/**\n * Normalize error to context object for error log method.\n * Uses 'err' key for Pino compatibility (Pino serializes Error objects on 'err' key).\n * Creates a shallow copy to avoid accidental mutation of the original object.\n */\nfunction normalizeErrorContext(error: unknown): Record<string, unknown> {\n if (error === undefined || error === null) {\n return {};\n }\n if (error instanceof Error) {\n return { err: error };\n }\n if (typeof error === 'object' && !Array.isArray(error)) {\n return { ...(error as Record<string, unknown>) };\n }\n return { err: error };\n}\n"]}
|
|
@@ -10,7 +10,7 @@ var safeLog = {
|
|
|
10
10
|
},
|
|
11
11
|
warn: (logger, msg, data) => {
|
|
12
12
|
if (!logger) return;
|
|
13
|
-
logger.warn(
|
|
13
|
+
logger.warn(normalizeWarnContext(data), msg);
|
|
14
14
|
},
|
|
15
15
|
error: (logger, msg, error) => {
|
|
16
16
|
if (!logger) return;
|
|
@@ -26,6 +26,18 @@ function normalizeContext(data) {
|
|
|
26
26
|
}
|
|
27
27
|
return { data };
|
|
28
28
|
}
|
|
29
|
+
function normalizeWarnContext(data) {
|
|
30
|
+
if (data === void 0 || data === null) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
if (data instanceof Error) {
|
|
34
|
+
return { err: data };
|
|
35
|
+
}
|
|
36
|
+
if (typeof data === "object" && !Array.isArray(data)) {
|
|
37
|
+
return { ...data };
|
|
38
|
+
}
|
|
39
|
+
return { data };
|
|
40
|
+
}
|
|
29
41
|
function normalizeErrorContext(error) {
|
|
30
42
|
if (error === void 0 || error === null) {
|
|
31
43
|
return {};
|
|
@@ -42,4 +54,4 @@ function normalizeErrorContext(error) {
|
|
|
42
54
|
export {
|
|
43
55
|
safeLog
|
|
44
56
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-P6WGW2FK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/observability.ts"],"sourcesContent":["/**\n * Observability types for emmett-expressjs-with-openapi.\n *\n * This module provides optional logging integration\n * following a \"silent by default\" philosophy.\n */\n\n/**\n * Canonical Logger contract for the Emmett ecosystem.\n *\n * This package defines the canonical Logger interface.\n * Implementations (Pino, Winston, etc.) MUST adapt to this contract.\n * This contract MUST NOT adapt to any specific implementation.\n *\n * Semantic Rules:\n * - context (first parameter): ALWAYS structured data as Record<string, unknown>\n * - message (second parameter): ALWAYS the human-readable log message\n * - The order is NEVER inverted\n * - The (message, data) form is NOT valid for this contract\n *\n * @example\n * ```typescript\n * // Pino - native compatibility\n * import pino from 'pino';\n * const logger = pino();\n * // logger.info({ orderId }, 'Order created') matches our contract\n * ```\n */\nexport interface Logger {\n /**\n * Log debug-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n debug(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log info-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n info(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log warn-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n warn(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log error-level message with structured context.\n * @param context - Structured data to include in the log entry (may include 'err' key)\n * @param message - Optional human-readable message\n */\n error(context: Record<string, unknown>, message?: string): void;\n}\n\n/**\n * Observability configuration options.\n */\nexport type ObservabilityOptions = {\n /**\n * Optional logger instance for diagnostic output.\n * When not provided, the library operates silently.\n *\n * @example\n * ```typescript\n * import pino from 'pino';\n *\n * const logger = pino();\n *\n * const app = await getApplication({\n * observability: { logger },\n * });\n * ```\n */\n logger?: Logger;\n};\n\n/**\n * Internal helper to safely call logger methods.\n *\n * IMPORTANT: safeLog is the ONLY translation point between internal usage\n * and the Logger contract.\n *\n * Internal Usage Pattern:\n * safeLog.info(logger, 'Order created', { orderId: 123 })\n *\n * Translation to Logger Contract:\n * logger.info({ orderId: 123 }, 'Order created')\n *\n * This allows ergonomic internal usage while ensuring all injected loggers\n * receive calls in the canonical (context, message) format.\n */\nexport const safeLog = {\n debug: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.debug(normalizeContext(data), msg);\n },\n info: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.info(normalizeContext(data), msg);\n },\n warn: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.warn(
|
|
1
|
+
{"version":3,"sources":["../src/observability.ts"],"sourcesContent":["/**\n * Observability types for emmett-expressjs-with-openapi.\n *\n * This module provides optional logging integration\n * following a \"silent by default\" philosophy.\n */\n\n/**\n * Canonical Logger contract for the Emmett ecosystem.\n *\n * This package defines the canonical Logger interface.\n * Implementations (Pino, Winston, etc.) MUST adapt to this contract.\n * This contract MUST NOT adapt to any specific implementation.\n *\n * Semantic Rules:\n * - context (first parameter): ALWAYS structured data as Record<string, unknown>\n * - message (second parameter): ALWAYS the human-readable log message\n * - The order is NEVER inverted\n * - The (message, data) form is NOT valid for this contract\n *\n * @example\n * ```typescript\n * // Pino - native compatibility\n * import pino from 'pino';\n * const logger = pino();\n * // logger.info({ orderId }, 'Order created') matches our contract\n * ```\n */\nexport interface Logger {\n /**\n * Log debug-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n debug(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log info-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n info(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log warn-level message with structured context.\n * @param context - Structured data to include in the log entry\n * @param message - Optional human-readable message\n */\n warn(context: Record<string, unknown>, message?: string): void;\n\n /**\n * Log error-level message with structured context.\n * @param context - Structured data to include in the log entry (may include 'err' key)\n * @param message - Optional human-readable message\n */\n error(context: Record<string, unknown>, message?: string): void;\n}\n\n/**\n * Observability configuration options.\n */\nexport type ObservabilityOptions = {\n /**\n * Optional logger instance for diagnostic output.\n * When not provided, the library operates silently.\n *\n * @example\n * ```typescript\n * import pino from 'pino';\n *\n * const logger = pino();\n *\n * const app = await getApplication({\n * observability: { logger },\n * });\n * ```\n */\n logger?: Logger;\n};\n\n/**\n * Internal helper to safely call logger methods.\n *\n * IMPORTANT: safeLog is the ONLY translation point between internal usage\n * and the Logger contract.\n *\n * Internal Usage Pattern:\n * safeLog.info(logger, 'Order created', { orderId: 123 })\n *\n * Translation to Logger Contract:\n * logger.info({ orderId: 123 }, 'Order created')\n *\n * This allows ergonomic internal usage while ensuring all injected loggers\n * receive calls in the canonical (context, message) format.\n */\nexport const safeLog = {\n debug: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.debug(normalizeContext(data), msg);\n },\n info: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.info(normalizeContext(data), msg);\n },\n warn: (logger: Logger | undefined, msg: string, data?: unknown) => {\n if (!logger) return;\n logger.warn(normalizeWarnContext(data), msg);\n },\n error: (logger: Logger | undefined, msg: string, error?: unknown) => {\n if (!logger) return;\n logger.error(normalizeErrorContext(error), msg);\n },\n};\n\n/**\n * Normalize data to context object for regular log methods.\n * Creates a shallow copy to avoid accidental mutation of the original object.\n */\nfunction normalizeContext(data: unknown): Record<string, unknown> {\n if (data === undefined || data === null) {\n return {};\n }\n if (typeof data === 'object' && !Array.isArray(data)) {\n return { ...(data as Record<string, unknown>) };\n }\n return { data };\n}\n\n/**\n * Normalize data to context object for warn log method.\n * Uses 'err' key for Error instances to prevent property leakage (like 'name' overwriting logger name).\n * Creates a shallow copy to avoid accidental mutation of the original object.\n */\nfunction normalizeWarnContext(data: unknown): Record<string, unknown> {\n if (data === undefined || data === null) {\n return {};\n }\n if (data instanceof Error) {\n return { err: data };\n }\n if (typeof data === 'object' && !Array.isArray(data)) {\n return { ...(data as Record<string, unknown>) };\n }\n return { data };\n}\n\n/**\n * Normalize error to context object for error log method.\n * Uses 'err' key for Pino compatibility (Pino serializes Error objects on 'err' key).\n * Creates a shallow copy to avoid accidental mutation of the original object.\n */\nfunction normalizeErrorContext(error: unknown): Record<string, unknown> {\n if (error === undefined || error === null) {\n return {};\n }\n if (error instanceof Error) {\n return { err: error };\n }\n if (typeof error === 'object' && !Array.isArray(error)) {\n return { ...(error as Record<string, unknown>) };\n }\n return { err: error };\n}\n"],"mappings":";AA+FO,IAAM,UAAU;AAAA,EACrB,OAAO,CAAC,QAA4B,KAAa,SAAmB;AAClE,QAAI,CAAC,OAAQ;AACb,WAAO,MAAM,iBAAiB,IAAI,GAAG,GAAG;AAAA,EAC1C;AAAA,EACA,MAAM,CAAC,QAA4B,KAAa,SAAmB;AACjE,QAAI,CAAC,OAAQ;AACb,WAAO,KAAK,iBAAiB,IAAI,GAAG,GAAG;AAAA,EACzC;AAAA,EACA,MAAM,CAAC,QAA4B,KAAa,SAAmB;AACjE,QAAI,CAAC,OAAQ;AACb,WAAO,KAAK,qBAAqB,IAAI,GAAG,GAAG;AAAA,EAC7C;AAAA,EACA,OAAO,CAAC,QAA4B,KAAa,UAAoB;AACnE,QAAI,CAAC,OAAQ;AACb,WAAO,MAAM,sBAAsB,KAAK,GAAG,GAAG;AAAA,EAChD;AACF;AAMA,SAAS,iBAAiB,MAAwC;AAChE,MAAI,SAAS,UAAa,SAAS,MAAM;AACvC,WAAO,CAAC;AAAA,EACV;AACA,MAAI,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG;AACpD,WAAO,EAAE,GAAI,KAAiC;AAAA,EAChD;AACA,SAAO,EAAE,KAAK;AAChB;AAOA,SAAS,qBAAqB,MAAwC;AACpE,MAAI,SAAS,UAAa,SAAS,MAAM;AACvC,WAAO,CAAC;AAAA,EACV;AACA,MAAI,gBAAgB,OAAO;AACzB,WAAO,EAAE,KAAK,KAAK;AAAA,EACrB;AACA,MAAI,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG;AACpD,WAAO,EAAE,GAAI,KAAiC;AAAA,EAChD;AACA,SAAO,EAAE,KAAK;AAChB;AAOA,SAAS,sBAAsB,OAAyC;AACtE,MAAI,UAAU,UAAa,UAAU,MAAM;AACzC,WAAO,CAAC;AAAA,EACV;AACA,MAAI,iBAAiB,OAAO;AAC1B,WAAO,EAAE,KAAK,MAAM;AAAA,EACtB;AACA,MAAI,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,GAAG;AACtD,WAAO,EAAE,GAAI,MAAkC;AAAA,EACjD;AACA,SAAO,EAAE,KAAK,MAAM;AACtB;","names":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkMRSGTROWcjs = require('./chunk-MRSGTROW.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkHX5NHAJYcjs = require('./chunk-HX5NHAJY.cjs');
|
|
7
|
+
require('./chunk-GS7T56RP.cjs');
|
|
8
|
+
|
|
9
|
+
// src/internal/handler-importer.ts
|
|
10
|
+
var _promises = require('fs/promises');
|
|
11
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
12
|
+
var _url = require('url');
|
|
13
|
+
var moduleExtensions = [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"];
|
|
14
|
+
var pathExists = async (filePath) => {
|
|
15
|
+
try {
|
|
16
|
+
await _promises.access.call(void 0, filePath);
|
|
17
|
+
return true;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var resolveModulePath = async (modulePath) => {
|
|
23
|
+
if (await pathExists(modulePath)) {
|
|
24
|
+
return modulePath;
|
|
25
|
+
}
|
|
26
|
+
if (_path2.default.extname(modulePath)) {
|
|
27
|
+
return modulePath;
|
|
28
|
+
}
|
|
29
|
+
for (const ext of moduleExtensions) {
|
|
30
|
+
const candidate = `${modulePath}${ext}`;
|
|
31
|
+
if (await pathExists(candidate)) {
|
|
32
|
+
return candidate;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return modulePath;
|
|
36
|
+
};
|
|
37
|
+
async function importAndRegisterHandlers(modules, logger) {
|
|
38
|
+
_chunkHX5NHAJYcjs.safeLog.debug(logger, "Importing handler modules", {
|
|
39
|
+
count: modules.length,
|
|
40
|
+
modules: modules.map((m) => m.moduleName)
|
|
41
|
+
});
|
|
42
|
+
const importedHandlers = {};
|
|
43
|
+
for (const module of modules) {
|
|
44
|
+
try {
|
|
45
|
+
const resolvedPath = await resolveModulePath(module.absolutePath);
|
|
46
|
+
_chunkHX5NHAJYcjs.safeLog.debug(logger, "Importing handler module", {
|
|
47
|
+
moduleName: module.moduleName,
|
|
48
|
+
absolutePath: module.absolutePath,
|
|
49
|
+
resolvedPath
|
|
50
|
+
});
|
|
51
|
+
const fileUrl = _url.pathToFileURL.call(void 0, resolvedPath).href;
|
|
52
|
+
const importedModule = await Promise.resolve().then(() => _interopRequireWildcard(require(fileUrl)));
|
|
53
|
+
_chunkMRSGTROWcjs.registerHandlerModule.call(void 0, module.absolutePath, importedModule);
|
|
54
|
+
if (resolvedPath !== module.absolutePath) {
|
|
55
|
+
_chunkMRSGTROWcjs.registerHandlerModule.call(void 0, resolvedPath, importedModule);
|
|
56
|
+
}
|
|
57
|
+
importedHandlers[module.moduleName] = importedModule;
|
|
58
|
+
_chunkHX5NHAJYcjs.safeLog.debug(logger, "Handler module imported successfully", {
|
|
59
|
+
moduleName: module.moduleName
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
_chunkHX5NHAJYcjs.safeLog.error(
|
|
63
|
+
logger,
|
|
64
|
+
`Failed to import handler module "${module.moduleName}"`,
|
|
65
|
+
error
|
|
66
|
+
);
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Failed to import handler module "${module.moduleName}" from ${module.absolutePath}: ${error.message}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return importedHandlers;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
exports.importAndRegisterHandlers = importAndRegisterHandlers;
|
|
77
|
+
//# sourceMappingURL=handler-importer-F73SZ2KQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/emmett-expressjs-with-openapi/emmett-expressjs-with-openapi/dist/handler-importer-F73SZ2KQ.cjs","../src/internal/handler-importer.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACCA,uCAAuB;AACvB,wEAAiB;AACjB,0BAA8B;AAO9B,IAAM,iBAAA,EAAmB,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAQ,MAAM,CAAA;AAEtE,IAAM,WAAA,EAAa,MAAA,CAAO,QAAA,EAAA,GAAuC;AAC/D,EAAA,IAAI;AACF,IAAA,MAAM,8BAAA,QAAe,CAAA;AACrB,IAAA,OAAO,IAAA;AAAA,EACT,EAAA,UAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF,CAAA;AAEA,IAAM,kBAAA,EAAoB,MAAA,CAAO,UAAA,EAAA,GAAwC;AACvE,EAAA,GAAA,CAAI,MAAM,UAAA,CAAW,UAAU,CAAA,EAAG;AAChC,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,cAAA,CAAK,OAAA,CAAQ,UAAU,CAAA,EAAG;AAC5B,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,IAAA,CAAA,MAAW,IAAA,GAAO,gBAAA,EAAkB;AAClC,IAAA,MAAM,UAAA,EAAY,CAAA,EAAA;AACR,IAAA;AACD,MAAA;AACT,IAAA;AACF,EAAA;AAEO,EAAA;AACT;AASsB;AAIN,EAAA;AACG,IAAA;AACE,IAAA;AAClB,EAAA;AAEK,EAAA;AAEe,EAAA;AACf,IAAA;AACI,MAAA;AAEQ,MAAA;AACA,QAAA;AACE,QAAA;AACd,QAAA;AACD,MAAA;AAGe,MAAA;AAGV,MAAA;AAGN,MAAA;AACI,MAAA;AACF,QAAA;AACF,MAAA;AAGiB,MAAA;AAEH,MAAA;AACA,QAAA;AACb,MAAA;AACa,IAAA;AACN,MAAA;AACN,QAAA;AACA,QAAA;AACA,QAAA;AACF,MAAA;AACU,MAAA;AACR,QAAA;AAGF,MAAA;AACF,IAAA;AACF,EAAA;AAEO,EAAA;AACT;ADpCuB;AACA;AACA","file":"/home/runner/work/emmett-expressjs-with-openapi/emmett-expressjs-with-openapi/dist/handler-importer-F73SZ2KQ.cjs","sourcesContent":[null,"/**\n * Handler module importer.\n *\n * INTERNAL MODULE - Not part of public API.\n *\n * Dynamically imports handler modules and registers them in the ESM resolver cache,\n * enabling automatic handler discovery without manual registration.\n */\n\nimport { access } from 'node:fs/promises';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type Logger, safeLog } from '../observability';\nimport { registerHandlerModule } from './esm-resolver.js';\nimport type { HandlerModuleInfo } from './openapi-parser.js';\n\nexport type ImportedHandlerModules = Record<string, any>;\n\nconst moduleExtensions = ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'];\n\nconst pathExists = async (filePath: string): Promise<boolean> => {\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n};\n\nconst resolveModulePath = async (modulePath: string): Promise<string> => {\n if (await pathExists(modulePath)) {\n return modulePath;\n }\n\n if (path.extname(modulePath)) {\n return modulePath;\n }\n\n for (const ext of moduleExtensions) {\n const candidate = `${modulePath}${ext}`;\n if (await pathExists(candidate)) {\n return candidate;\n }\n }\n\n return modulePath;\n};\n\n/**\n * Dynamically import and register all handler modules.\n *\n * @param modules - Handler module information from OpenAPI parser\n * @param logger - Optional logger for debug output\n * @returns Object containing all imported modules, keyed by module name\n */\nexport async function importAndRegisterHandlers(\n modules: HandlerModuleInfo[],\n logger?: Logger,\n): Promise<ImportedHandlerModules> {\n safeLog.debug(logger, 'Importing handler modules', {\n count: modules.length,\n modules: modules.map((m) => m.moduleName),\n });\n\n const importedHandlers: ImportedHandlerModules = {};\n\n for (const module of modules) {\n try {\n const resolvedPath = await resolveModulePath(module.absolutePath);\n\n safeLog.debug(logger, 'Importing handler module', {\n moduleName: module.moduleName,\n absolutePath: module.absolutePath,\n resolvedPath,\n });\n\n // Convert to file:// URL for dynamic import\n const fileUrl = pathToFileURL(resolvedPath).href;\n\n // Dynamically import the handler module\n const importedModule = await import(fileUrl);\n\n // Register in ESM resolver cache\n registerHandlerModule(module.absolutePath, importedModule);\n if (resolvedPath !== module.absolutePath) {\n registerHandlerModule(resolvedPath, importedModule);\n }\n\n // Store in result object keyed by module name\n importedHandlers[module.moduleName] = importedModule;\n\n safeLog.debug(logger, 'Handler module imported successfully', {\n moduleName: module.moduleName,\n });\n } catch (error) {\n safeLog.error(\n logger,\n `Failed to import handler module \"${module.moduleName}\"`,\n error,\n );\n throw new Error(\n `Failed to import handler module \"${module.moduleName}\" from ${module.absolutePath}: ${\n (error as Error).message\n }`,\n );\n }\n }\n\n return importedHandlers;\n}\n"]}
|
|
@@ -3,10 +3,36 @@ import {
|
|
|
3
3
|
} from "./chunk-5TC7YUZR.js";
|
|
4
4
|
import {
|
|
5
5
|
safeLog
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-P6WGW2FK.js";
|
|
7
7
|
|
|
8
8
|
// src/internal/handler-importer.ts
|
|
9
|
+
import { access } from "fs/promises";
|
|
10
|
+
import path from "path";
|
|
9
11
|
import { pathToFileURL } from "url";
|
|
12
|
+
var moduleExtensions = [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"];
|
|
13
|
+
var pathExists = async (filePath) => {
|
|
14
|
+
try {
|
|
15
|
+
await access(filePath);
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var resolveModulePath = async (modulePath) => {
|
|
22
|
+
if (await pathExists(modulePath)) {
|
|
23
|
+
return modulePath;
|
|
24
|
+
}
|
|
25
|
+
if (path.extname(modulePath)) {
|
|
26
|
+
return modulePath;
|
|
27
|
+
}
|
|
28
|
+
for (const ext of moduleExtensions) {
|
|
29
|
+
const candidate = `${modulePath}${ext}`;
|
|
30
|
+
if (await pathExists(candidate)) {
|
|
31
|
+
return candidate;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return modulePath;
|
|
35
|
+
};
|
|
10
36
|
async function importAndRegisterHandlers(modules, logger) {
|
|
11
37
|
safeLog.debug(logger, "Importing handler modules", {
|
|
12
38
|
count: modules.length,
|
|
@@ -15,13 +41,18 @@ async function importAndRegisterHandlers(modules, logger) {
|
|
|
15
41
|
const importedHandlers = {};
|
|
16
42
|
for (const module of modules) {
|
|
17
43
|
try {
|
|
44
|
+
const resolvedPath = await resolveModulePath(module.absolutePath);
|
|
18
45
|
safeLog.debug(logger, "Importing handler module", {
|
|
19
46
|
moduleName: module.moduleName,
|
|
20
|
-
absolutePath: module.absolutePath
|
|
47
|
+
absolutePath: module.absolutePath,
|
|
48
|
+
resolvedPath
|
|
21
49
|
});
|
|
22
|
-
const fileUrl = pathToFileURL(
|
|
50
|
+
const fileUrl = pathToFileURL(resolvedPath).href;
|
|
23
51
|
const importedModule = await import(fileUrl);
|
|
24
52
|
registerHandlerModule(module.absolutePath, importedModule);
|
|
53
|
+
if (resolvedPath !== module.absolutePath) {
|
|
54
|
+
registerHandlerModule(resolvedPath, importedModule);
|
|
55
|
+
}
|
|
25
56
|
importedHandlers[module.moduleName] = importedModule;
|
|
26
57
|
safeLog.debug(logger, "Handler module imported successfully", {
|
|
27
58
|
moduleName: module.moduleName
|
|
@@ -42,4 +73,4 @@ async function importAndRegisterHandlers(modules, logger) {
|
|
|
42
73
|
export {
|
|
43
74
|
importAndRegisterHandlers
|
|
44
75
|
};
|
|
45
|
-
//# sourceMappingURL=handler-importer-
|
|
76
|
+
//# sourceMappingURL=handler-importer-SE6HRBDZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/handler-importer.ts"],"sourcesContent":["/**\n * Handler module importer.\n *\n * INTERNAL MODULE - Not part of public API.\n *\n * Dynamically imports handler modules and registers them in the ESM resolver cache,\n * enabling automatic handler discovery without manual registration.\n */\n\nimport { access } from 'node:fs/promises';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type Logger, safeLog } from '../observability';\nimport { registerHandlerModule } from './esm-resolver.js';\nimport type { HandlerModuleInfo } from './openapi-parser.js';\n\nexport type ImportedHandlerModules = Record<string, any>;\n\nconst moduleExtensions = ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'];\n\nconst pathExists = async (filePath: string): Promise<boolean> => {\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n};\n\nconst resolveModulePath = async (modulePath: string): Promise<string> => {\n if (await pathExists(modulePath)) {\n return modulePath;\n }\n\n if (path.extname(modulePath)) {\n return modulePath;\n }\n\n for (const ext of moduleExtensions) {\n const candidate = `${modulePath}${ext}`;\n if (await pathExists(candidate)) {\n return candidate;\n }\n }\n\n return modulePath;\n};\n\n/**\n * Dynamically import and register all handler modules.\n *\n * @param modules - Handler module information from OpenAPI parser\n * @param logger - Optional logger for debug output\n * @returns Object containing all imported modules, keyed by module name\n */\nexport async function importAndRegisterHandlers(\n modules: HandlerModuleInfo[],\n logger?: Logger,\n): Promise<ImportedHandlerModules> {\n safeLog.debug(logger, 'Importing handler modules', {\n count: modules.length,\n modules: modules.map((m) => m.moduleName),\n });\n\n const importedHandlers: ImportedHandlerModules = {};\n\n for (const module of modules) {\n try {\n const resolvedPath = await resolveModulePath(module.absolutePath);\n\n safeLog.debug(logger, 'Importing handler module', {\n moduleName: module.moduleName,\n absolutePath: module.absolutePath,\n resolvedPath,\n });\n\n // Convert to file:// URL for dynamic import\n const fileUrl = pathToFileURL(resolvedPath).href;\n\n // Dynamically import the handler module\n const importedModule = await import(fileUrl);\n\n // Register in ESM resolver cache\n registerHandlerModule(module.absolutePath, importedModule);\n if (resolvedPath !== module.absolutePath) {\n registerHandlerModule(resolvedPath, importedModule);\n }\n\n // Store in result object keyed by module name\n importedHandlers[module.moduleName] = importedModule;\n\n safeLog.debug(logger, 'Handler module imported successfully', {\n moduleName: module.moduleName,\n });\n } catch (error) {\n safeLog.error(\n logger,\n `Failed to import handler module \"${module.moduleName}\"`,\n error,\n );\n throw new Error(\n `Failed to import handler module \"${module.moduleName}\" from ${module.absolutePath}: ${\n (error as Error).message\n }`,\n );\n }\n }\n\n return importedHandlers;\n}\n"],"mappings":";;;;;;;;AASA,SAAS,cAAc;AACvB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAO9B,IAAM,mBAAmB,CAAC,OAAO,QAAQ,QAAQ,OAAO,QAAQ,MAAM;AAEtE,IAAM,aAAa,OAAO,aAAuC;AAC/D,MAAI;AACF,UAAM,OAAO,QAAQ;AACrB,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAM,oBAAoB,OAAO,eAAwC;AACvE,MAAI,MAAM,WAAW,UAAU,GAAG;AAChC,WAAO;AAAA,EACT;AAEA,MAAI,KAAK,QAAQ,UAAU,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,aAAW,OAAO,kBAAkB;AAClC,UAAM,YAAY,GAAG,UAAU,GAAG,GAAG;AACrC,QAAI,MAAM,WAAW,SAAS,GAAG;AAC/B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AASA,eAAsB,0BACpB,SACA,QACiC;AACjC,UAAQ,MAAM,QAAQ,6BAA6B;AAAA,IACjD,OAAO,QAAQ;AAAA,IACf,SAAS,QAAQ,IAAI,CAAC,MAAM,EAAE,UAAU;AAAA,EAC1C,CAAC;AAED,QAAM,mBAA2C,CAAC;AAElD,aAAW,UAAU,SAAS;AAC5B,QAAI;AACF,YAAM,eAAe,MAAM,kBAAkB,OAAO,YAAY;AAEhE,cAAQ,MAAM,QAAQ,4BAA4B;AAAA,QAChD,YAAY,OAAO;AAAA,QACnB,cAAc,OAAO;AAAA,QACrB;AAAA,MACF,CAAC;AAGD,YAAM,UAAU,cAAc,YAAY,EAAE;AAG5C,YAAM,iBAAiB,MAAM,OAAO;AAGpC,4BAAsB,OAAO,cAAc,cAAc;AACzD,UAAI,iBAAiB,OAAO,cAAc;AACxC,8BAAsB,cAAc,cAAc;AAAA,MACpD;AAGA,uBAAiB,OAAO,UAAU,IAAI;AAEtC,cAAQ,MAAM,QAAQ,wCAAwC;AAAA,QAC5D,YAAY,OAAO;AAAA,MACrB,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ;AAAA,QACN;AAAA,QACA,oCAAoC,OAAO,UAAU;AAAA,QACrD;AAAA,MACF;AACA,YAAM,IAAI;AAAA,QACR,oCAAoC,OAAO,UAAU,UAAU,OAAO,YAAY,KAC/E,MAAgB,OACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkMRSGTROWcjs = require('./chunk-MRSGTROW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkHX5NHAJYcjs = require('./chunk-HX5NHAJY.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -23,10 +23,14 @@ var _module = require('module');
|
|
|
23
23
|
// src/middlewares/problemDetailsMiddleware.ts
|
|
24
24
|
var _httpproblemdetails = require('http-problem-details');
|
|
25
25
|
var problemDetailsMiddleware = (mapError, logger) => (error, request, response, _next) => {
|
|
26
|
-
_chunkFSPH5TRTcjs.safeLog.error(logger, "Request error", error);
|
|
27
26
|
let problemDetails;
|
|
28
27
|
if (mapError) problemDetails = mapError(error, request);
|
|
29
28
|
problemDetails = _nullishCoalesce(problemDetails, () => ( defaultErrorToProblemDetailsMapping(error)));
|
|
29
|
+
if (problemDetails.status >= 500) {
|
|
30
|
+
_chunkHX5NHAJYcjs.safeLog.error(logger, "Server error", error);
|
|
31
|
+
} else {
|
|
32
|
+
_chunkHX5NHAJYcjs.safeLog.warn(logger, "Client error", error);
|
|
33
|
+
}
|
|
30
34
|
sendProblem(response, problemDetails.status, { problem: problemDetails });
|
|
31
35
|
};
|
|
32
36
|
var defaultErrorToProblemDetailsMapping = (error) => {
|
|
@@ -62,7 +66,7 @@ var getApplication = async (options) => {
|
|
|
62
66
|
observability
|
|
63
67
|
} = options;
|
|
64
68
|
const logger = _optionalChain([observability, 'optionalAccess', _ => _.logger]);
|
|
65
|
-
|
|
69
|
+
_chunkHX5NHAJYcjs.safeLog.debug(logger, "Initializing Express application", {
|
|
66
70
|
hasApis: !!_optionalChain([apis, 'optionalAccess', _2 => _2.length]),
|
|
67
71
|
hasOpenApiValidator: !!openApiValidator,
|
|
68
72
|
hasPinoHttp: !!pinoHttp
|
|
@@ -81,7 +85,7 @@ var getApplication = async (options) => {
|
|
|
81
85
|
const middleware = provider(options2);
|
|
82
86
|
app.use(middleware);
|
|
83
87
|
} catch (error) {
|
|
84
|
-
|
|
88
|
+
_chunkHX5NHAJYcjs.safeLog.warn(
|
|
85
89
|
logger,
|
|
86
90
|
"Pino HTTP configuration provided but pino-http package is not installed. Install it with: npm install pino-http"
|
|
87
91
|
);
|
|
@@ -103,8 +107,8 @@ var getApplication = async (options) => {
|
|
|
103
107
|
activateESMResolver();
|
|
104
108
|
const handlersBasePath = typeof openApiValidator.operationHandlers === "string" ? openApiValidator.operationHandlers : openApiValidator.operationHandlers.basePath;
|
|
105
109
|
if (handlersBasePath) {
|
|
106
|
-
const { extractHandlerModules } = await Promise.resolve().then(() => _interopRequireWildcard(require("./openapi-parser-
|
|
107
|
-
const { importAndRegisterHandlers } = await Promise.resolve().then(() => _interopRequireWildcard(require("./handler-importer-
|
|
110
|
+
const { extractHandlerModules } = await Promise.resolve().then(() => _interopRequireWildcard(require("./openapi-parser-G4KTMZEZ.cjs")));
|
|
111
|
+
const { importAndRegisterHandlers } = await Promise.resolve().then(() => _interopRequireWildcard(require("./handler-importer-F73SZ2KQ.cjs")));
|
|
108
112
|
const modules = await tracer.startActiveSpan(
|
|
109
113
|
"emmett.openapi.parse_spec",
|
|
110
114
|
async (span) => {
|
|
@@ -138,7 +142,7 @@ var getApplication = async (options) => {
|
|
|
138
142
|
span.setStatus({ code: _api.SpanStatusCode.OK });
|
|
139
143
|
return result;
|
|
140
144
|
} catch (error) {
|
|
141
|
-
|
|
145
|
+
_chunkHX5NHAJYcjs.safeLog.error(logger, "Failed to auto-import handler modules", error);
|
|
142
146
|
span.recordException(error);
|
|
143
147
|
span.setStatus({ code: _api.SpanStatusCode.ERROR });
|
|
144
148
|
throw error;
|
|
@@ -185,7 +189,7 @@ var getApplication = async (options) => {
|
|
|
185
189
|
app.use(middleware);
|
|
186
190
|
}
|
|
187
191
|
} catch (error) {
|
|
188
|
-
|
|
192
|
+
_chunkHX5NHAJYcjs.safeLog.warn(
|
|
189
193
|
logger,
|
|
190
194
|
"OpenAPI validator configuration provided but express-openapi-validator package is not installed. Install it with: npm install express-openapi-validator"
|
|
191
195
|
);
|
|
@@ -202,14 +206,14 @@ var getApplication = async (options) => {
|
|
|
202
206
|
}
|
|
203
207
|
if (!disableProblemDetailsMiddleware)
|
|
204
208
|
app.use(problemDetailsMiddleware(mapError, logger));
|
|
205
|
-
|
|
209
|
+
_chunkHX5NHAJYcjs.safeLog.info(logger, "Express application initialized");
|
|
206
210
|
return app;
|
|
207
211
|
};
|
|
208
212
|
var startAPI = (app, options = { port: 3e3 }) => {
|
|
209
213
|
const { port, logger } = options;
|
|
210
214
|
const server = _http2.default.createServer(app);
|
|
211
215
|
server.on("listening", () => {
|
|
212
|
-
|
|
216
|
+
_chunkHX5NHAJYcjs.safeLog.info(logger, "Server up listening", { port });
|
|
213
217
|
});
|
|
214
218
|
return server.listen(port);
|
|
215
219
|
};
|
|
@@ -578,5 +582,5 @@ var ApiSpecification = {
|
|
|
578
582
|
|
|
579
583
|
|
|
580
584
|
|
|
581
|
-
exports.Accepted = Accepted; exports.ApiE2ESpecification = ApiE2ESpecification; exports.ApiSpecification = ApiSpecification; exports.BadRequest = BadRequest; exports.Conflict = Conflict; exports.Created = Created; exports.DefaultHttpProblemResponseOptions = DefaultHttpProblemResponseOptions; exports.DefaultHttpResponseOptions = DefaultHttpResponseOptions; exports.ETagErrors = ETagErrors; exports.Forbidden = Forbidden; exports.HeaderNames = HeaderNames; exports.HttpProblem = HttpProblem; exports.HttpResponse = HttpResponse; exports.NoContent = NoContent; exports.NotFound = NotFound; exports.OK = OK; exports.PreconditionFailed = PreconditionFailed; exports.WeakETagRegex = WeakETagRegex; exports.createFirebaseAuthSecurityHandlers = createFirebaseAuthSecurityHandlers; exports.createOpenApiValidatorOptions = createOpenApiValidatorOptions; exports.existingStream = existingStream; exports.expect = expect; exports.expectError = expectError; exports.expectNewEvents = expectNewEvents; exports.expectResponse = expectResponse; exports.getApplication = getApplication; exports.getETagFromIfMatch = getETagFromIfMatch; exports.getETagFromIfNotMatch = getETagFromIfNotMatch; exports.getETagValueFromIfMatch = getETagValueFromIfMatch; exports.getWeakETagValue = getWeakETagValue; exports.isOpenApiValidatorAvailable = isOpenApiValidatorAvailable; exports.isWeakETag = isWeakETag; exports.on = on; exports.registerHandlerModule = _chunkMRSGTROWcjs.registerHandlerModule; exports.safeLog =
|
|
585
|
+
exports.Accepted = Accepted; exports.ApiE2ESpecification = ApiE2ESpecification; exports.ApiSpecification = ApiSpecification; exports.BadRequest = BadRequest; exports.Conflict = Conflict; exports.Created = Created; exports.DefaultHttpProblemResponseOptions = DefaultHttpProblemResponseOptions; exports.DefaultHttpResponseOptions = DefaultHttpResponseOptions; exports.ETagErrors = ETagErrors; exports.Forbidden = Forbidden; exports.HeaderNames = HeaderNames; exports.HttpProblem = HttpProblem; exports.HttpResponse = HttpResponse; exports.NoContent = NoContent; exports.NotFound = NotFound; exports.OK = OK; exports.PreconditionFailed = PreconditionFailed; exports.WeakETagRegex = WeakETagRegex; exports.createFirebaseAuthSecurityHandlers = createFirebaseAuthSecurityHandlers; exports.createOpenApiValidatorOptions = createOpenApiValidatorOptions; exports.existingStream = existingStream; exports.expect = expect; exports.expectError = expectError; exports.expectNewEvents = expectNewEvents; exports.expectResponse = expectResponse; exports.getApplication = getApplication; exports.getETagFromIfMatch = getETagFromIfMatch; exports.getETagFromIfNotMatch = getETagFromIfNotMatch; exports.getETagValueFromIfMatch = getETagValueFromIfMatch; exports.getWeakETagValue = getWeakETagValue; exports.isOpenApiValidatorAvailable = isOpenApiValidatorAvailable; exports.isWeakETag = isWeakETag; exports.on = on; exports.registerHandlerModule = _chunkMRSGTROWcjs.registerHandlerModule; exports.safeLog = _chunkHX5NHAJYcjs.safeLog; exports.send = send; exports.sendAccepted = sendAccepted; exports.sendCreated = sendCreated; exports.sendProblem = sendProblem; exports.setETag = setETag; exports.startAPI = startAPI; exports.toWeakETag = toWeakETag; exports.tracedOn = tracedOn;
|
|
582
586
|
//# sourceMappingURL=index.cjs.map
|