http-response-kit 1.0.0 → 2.0.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.
Files changed (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +357 -272
  3. package/dist/chunk-373JVXMN.mjs +1199 -0
  4. package/dist/chunk-373JVXMN.mjs.map +1 -0
  5. package/dist/chunk-FFRB2EUE.mjs +36 -0
  6. package/dist/chunk-FFRB2EUE.mjs.map +1 -0
  7. package/dist/express.d.mts +50 -0
  8. package/dist/express.d.ts +50 -0
  9. package/dist/express.js +1155 -0
  10. package/dist/express.js.map +1 -0
  11. package/dist/express.mjs +28 -0
  12. package/dist/express.mjs.map +1 -0
  13. package/dist/fastify.d.mts +45 -0
  14. package/dist/fastify.d.ts +45 -0
  15. package/dist/fastify.js +1170 -0
  16. package/dist/fastify.js.map +1 -0
  17. package/dist/fastify.mjs +43 -0
  18. package/dist/fastify.mjs.map +1 -0
  19. package/dist/hono.d.mts +33 -0
  20. package/dist/hono.d.ts +33 -0
  21. package/dist/hono.js +1139 -0
  22. package/dist/hono.js.map +1 -0
  23. package/dist/hono.mjs +18 -0
  24. package/dist/hono.mjs.map +1 -0
  25. package/dist/index.d.mts +75 -493
  26. package/dist/index.d.ts +75 -493
  27. package/dist/index.js +480 -180
  28. package/dist/index.js.map +1 -0
  29. package/dist/index.mjs +18 -891
  30. package/dist/index.mjs.map +1 -0
  31. package/dist/kit-nHfihlKE.d.mts +753 -0
  32. package/dist/kit-nHfihlKE.d.ts +753 -0
  33. package/dist/koa.d.mts +38 -0
  34. package/dist/koa.d.ts +38 -0
  35. package/dist/koa.js +1150 -0
  36. package/dist/koa.js.map +1 -0
  37. package/dist/koa.mjs +24 -0
  38. package/dist/koa.mjs.map +1 -0
  39. package/dist/schemas.d.mts +452 -0
  40. package/dist/schemas.d.ts +452 -0
  41. package/dist/schemas.js +124 -0
  42. package/dist/schemas.js.map +1 -0
  43. package/dist/schemas.mjs +119 -0
  44. package/dist/schemas.mjs.map +1 -0
  45. package/dist/shared-Czwmz6Xa.d.ts +22 -0
  46. package/dist/shared-DYq1Fic4.d.mts +22 -0
  47. package/package.json +104 -49
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants/error-definitions.ts","../src/errors/system-errors.ts","../src/errors/HttpError.ts","../src/constants/success-definitions.ts","../src/kit.ts","../src/responses/problem.ts","../src/adapters/shared.ts","../src/adapters/express.ts"],"names":[],"mappings":";;;AAWO,IAAM,oBAAA,GAAsD;AAAA;AAAA;AAAA;AAAA,EAK/D,yBAAmC;AAAA,IAC/B,IAAA,EAAM,aAAA;AAAA,IACN,KAAA,EAAO,aAAA;AAAA,IACP,IAAA,EAAM,GAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACb;AAAA,EAEA,0BAAoC;AAAA,IAChC,IAAA,EAAM,cAAA;AAAA,IACN,KAAA,EAAO,cAAA;AAAA,IACP,IAAA,EAAM,GAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACb;AAAA,EAEA,8BAAwC;AAAA,IACpC,IAAA,EAAM,kBAAA;AAAA,IACN,KAAA,EAAO,kBAAA;AAAA,IACP,IAAA,EAAM,GAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACb;AAAA,EAEA,uBAAiC;AAAA,IAC7B,IAAA,EAAM,WAAA;AAAA,IACN,KAAA,EAAO,WAAA;AAAA,IACP,IAAA,EAAM,GAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACb;AAAA,EAEA,uBAAiC;AAAA,IAC7B,IAAA,EAAM,WAAA;AAAA,IACN,KAAA,EAAO,WAAA;AAAA,IACP,IAAA,EAAM,GAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACb;AAAA,EAEA,gCAA0C;AAAA,IACtC,IAAA,EAAM,oBAAA;AAAA,IACN,KAAA,EAAO,oBAAA;AAAA,IACP,IAAA,EAAM,GAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACb;AAAA,EAEA,4BAAsC;AAAA,IAClC,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CAAA,MAAA,EAAS,GAAA,CAAI,UAAU,EAAE,CAAA,CAAA,EAAI,GAAA,CAAI,WAAA,IAAe,IAAI,GAAA,IAAO,EAAE,CAAA,UAAA,CAAA,CAAa,IAAA,EAAM,CAAC,CAAA;AAAA,EACxH,CAAA;AACJ","file":"express.js","sourcesContent":["/**\n * HTTP Response Kit - Error Definitions\n * @module constants/error-definitions\n */\n\nimport type { HttpErrorInfo } from '../types';\nimport { HttpClientErrorCode, HttpServerErrorCode } from './status-codes';\n\n/**\n * Complete definitions for all HTTP error types (4xx and 5xx)\n */\nexport const HttpErrorDefinitions: Record<number, HttpErrorInfo> = {\n // ========================================================================\n // 4xx Client Errors\n // ========================================================================\n\n [HttpClientErrorCode.BAD_REQUEST]: {\n type: 'bad_request',\n title: 'Bad Request',\n code: 400,\n details: 'The request cannot be processed due to invalid syntax or missing parameters.',\n },\n\n [HttpClientErrorCode.UNAUTHORIZED]: {\n type: 'unauthorized',\n title: 'Unauthorized',\n code: 401,\n details: 'Authentication is required and has failed or not yet been provided.',\n },\n\n [HttpClientErrorCode.PAYMENT_REQUIRED]: {\n type: 'payment_required',\n title: 'Payment Required',\n code: 402,\n details: 'Payment is required to access this resource.',\n },\n\n [HttpClientErrorCode.FORBIDDEN]: {\n type: 'forbidden',\n title: 'Forbidden',\n code: 403,\n details: 'The server understood the request but refuses to authorize it.',\n },\n\n [HttpClientErrorCode.NOT_FOUND]: {\n type: 'not_found',\n title: 'Not Found',\n code: 404,\n details: 'The requested resource could not be found.',\n },\n\n [HttpClientErrorCode.METHOD_NOT_ALLOWED]: {\n type: 'method_not_allowed',\n title: 'Method Not Allowed',\n code: 405,\n details: 'The method specified in the request is not allowed for the resource.',\n },\n\n [HttpClientErrorCode.NOT_ACCEPTABLE]: {\n type: 'not_acceptable',\n title: 'Not Acceptable',\n code: 406,\n details: 'The resource is not available in a format acceptable to the client.',\n },\n\n [HttpClientErrorCode.PROXY_AUTHENTICATION_REQUIRED]: {\n type: 'proxy_authentication_required',\n title: 'Proxy Authentication Required',\n code: 407,\n details: 'Authentication with the proxy is required.',\n },\n\n [HttpClientErrorCode.REQUEST_TIMEOUT]: {\n type: 'request_timeout',\n title: 'Request Timeout',\n code: 408,\n details: 'The server timed out waiting for the request.',\n },\n\n [HttpClientErrorCode.CONFLICT]: {\n type: 'conflict',\n title: 'Conflict',\n code: 409,\n details: 'The request conflicts with the current state of the resource.',\n },\n\n [HttpClientErrorCode.GONE]: {\n type: 'gone',\n title: 'Gone',\n code: 410,\n details: 'The requested resource is no longer available and will not be available again.',\n },\n\n [HttpClientErrorCode.LENGTH_REQUIRED]: {\n type: 'length_required',\n title: 'Length Required',\n code: 411,\n details: 'The request did not specify the length of its content, which is required.',\n },\n\n [HttpClientErrorCode.PRECONDITION_FAILED]: {\n type: 'precondition_failed',\n title: 'Precondition Failed',\n code: 412,\n details: 'One or more conditions in the request header fields evaluated to false.',\n },\n\n [HttpClientErrorCode.PAYLOAD_TOO_LARGE]: {\n type: 'payload_too_large',\n title: 'Payload Too Large',\n code: 413,\n details: 'The request payload is larger than the server is willing to process.',\n },\n\n [HttpClientErrorCode.URI_TOO_LONG]: {\n type: 'uri_too_long',\n title: 'URI Too Long',\n code: 414,\n details: 'The URI provided was too long for the server to process.',\n },\n\n [HttpClientErrorCode.UNSUPPORTED_MEDIA_TYPE]: {\n type: 'unsupported_media_type',\n title: 'Unsupported Media Type',\n code: 415,\n details: 'The media format of the requested data is not supported by the server.',\n },\n\n [HttpClientErrorCode.RANGE_NOT_SATISFIABLE]: {\n type: 'range_not_satisfiable',\n title: 'Range Not Satisfiable',\n code: 416,\n details: 'The range specified in the request header cannot be fulfilled.',\n },\n\n [HttpClientErrorCode.EXPECTATION_FAILED]: {\n type: 'expectation_failed',\n title: 'Expectation Failed',\n code: 417,\n details: 'The server cannot meet the requirements of the Expect request-header field.',\n },\n\n [HttpClientErrorCode.IM_A_TEAPOT]: {\n type: 'im_a_teapot',\n title: \"I'm a Teapot\",\n code: 418,\n details: 'The server refuses to brew coffee because it is, permanently, a teapot.',\n },\n\n [HttpClientErrorCode.MISDIRECTED_REQUEST]: {\n type: 'misdirected_request',\n title: 'Misdirected Request',\n code: 421,\n details: 'The request was directed at a server that is not able to produce a response.',\n },\n\n [HttpClientErrorCode.UNPROCESSABLE_ENTITY]: {\n type: 'unprocessable_entity',\n title: 'Unprocessable Entity',\n code: 422,\n details: 'The request was well-formed but was unable to be followed due to semantic errors.',\n },\n\n [HttpClientErrorCode.LOCKED]: {\n type: 'locked',\n title: 'Locked',\n code: 423,\n details: 'The resource that is being accessed is locked.',\n },\n\n [HttpClientErrorCode.FAILED_DEPENDENCY]: {\n type: 'failed_dependency',\n title: 'Failed Dependency',\n code: 424,\n details: 'The request failed because it depended on another request that failed.',\n },\n\n [HttpClientErrorCode.TOO_EARLY]: {\n type: 'too_early',\n title: 'Too Early',\n code: 425,\n details: 'The server is unwilling to risk processing a request that might be replayed.',\n },\n\n [HttpClientErrorCode.UPGRADE_REQUIRED]: {\n type: 'upgrade_required',\n title: 'Upgrade Required',\n code: 426,\n details: 'The client should switch to a different protocol.',\n },\n\n [HttpClientErrorCode.PRECONDITION_REQUIRED]: {\n type: 'precondition_required',\n title: 'Precondition Required',\n code: 428,\n details: 'The origin server requires the request to be conditional.',\n },\n\n [HttpClientErrorCode.TOO_MANY_REQUESTS]: {\n type: 'too_many_requests',\n title: 'Too Many Requests',\n code: 429,\n details: 'The user has sent too many requests in a given amount of time.',\n retryAfter: 60,\n },\n\n [HttpClientErrorCode.REQUEST_HEADER_FIELDS_TOO_LARGE]: {\n type: 'request_header_fields_too_large',\n title: 'Request Header Fields Too Large',\n code: 431,\n details: 'The server is unwilling to process the request because its header fields are too large.',\n },\n\n [HttpClientErrorCode.UNAVAILABLE_FOR_LEGAL_REASONS]: {\n type: 'unavailable_for_legal_reasons',\n title: 'Unavailable For Legal Reasons',\n code: 451,\n details: 'The resource is unavailable due to legal demands.',\n },\n\n // ========================================================================\n // 5xx Server Errors\n // ========================================================================\n\n [HttpServerErrorCode.INTERNAL_SERVER_ERROR]: {\n type: 'internal_server_error',\n title: 'Internal Server Error',\n code: 500,\n details: 'An unexpected error occurred on the server.',\n },\n\n [HttpServerErrorCode.NOT_IMPLEMENTED]: {\n type: 'not_implemented',\n title: 'Not Implemented',\n code: 501,\n details: 'The server does not support the functionality required to fulfill the request.',\n },\n\n [HttpServerErrorCode.BAD_GATEWAY]: {\n type: 'bad_gateway',\n title: 'Bad Gateway',\n code: 502,\n details: 'The server received an invalid response from an upstream server.',\n },\n\n [HttpServerErrorCode.SERVICE_UNAVAILABLE]: {\n type: 'service_unavailable',\n title: 'Service Unavailable',\n code: 503,\n details: 'The server is currently unable to handle the request due to temporary overloading or maintenance.',\n retryAfter: 60,\n resolution: 'Try again after a short period or contact support.',\n },\n\n [HttpServerErrorCode.GATEWAY_TIMEOUT]: {\n type: 'gateway_timeout',\n title: 'Gateway Timeout',\n code: 504,\n details: 'The server did not receive a timely response from an upstream server.',\n },\n\n [HttpServerErrorCode.HTTP_VERSION_NOT_SUPPORTED]: {\n type: 'http_version_not_supported',\n title: 'HTTP Version Not Supported',\n code: 505,\n details: 'The server does not support the HTTP protocol version used in the request.',\n },\n\n [HttpServerErrorCode.VARIANT_ALSO_NEGOTIATES]: {\n type: 'variant_also_negotiates',\n title: 'Variant Also Negotiates',\n code: 506,\n details: 'The server has an internal configuration error during content negotiation.',\n },\n\n [HttpServerErrorCode.INSUFFICIENT_STORAGE]: {\n type: 'insufficient_storage',\n title: 'Insufficient Storage',\n code: 507,\n details: 'The server is unable to store the representation needed to complete the request.',\n },\n\n [HttpServerErrorCode.LOOP_DETECTED]: {\n type: 'loop_detected',\n title: 'Loop Detected',\n code: 508,\n details: 'The server detected an infinite loop while processing the request.',\n },\n\n [HttpServerErrorCode.BANDWIDTH_LIMIT_EXCEEDED]: {\n type: 'bandwidth_limit_exceeded',\n title: 'Bandwidth Limit Exceeded',\n code: 509,\n details: 'The server has exceeded the bandwidth limit.',\n },\n\n [HttpServerErrorCode.NOT_EXTENDED]: {\n type: 'not_extended',\n title: 'Not Extended',\n code: 510,\n details: 'Further extensions to the request are required for the server to fulfill it.',\n },\n\n [HttpServerErrorCode.NETWORK_AUTHENTICATION_REQUIRED]: {\n type: 'network_authentication_required',\n title: 'Network Authentication Required',\n code: 511,\n details: 'The client needs to authenticate to gain network access.',\n },\n} as const;\n\nObject.freeze(HttpErrorDefinitions);\n\n/**\n * Get error definition by status code\n */\nexport function getErrorDefinition(code: number): HttpErrorInfo {\n if (code < 400 || code > 599) {\n throw new RangeError(\n `Invalid HTTP error code: ${code}. Must be between 400 and 599.`\n );\n }\n\n if (HttpErrorDefinitions[code]) {\n return HttpErrorDefinitions[code];\n }\n\n // Preserve the original code but provide a generic fallback definition\n const isClientError = code >= 400 && code < 500;\n return {\n type: isClientError ? 'unknown_client_error' : 'unknown_server_error',\n title: isClientError ? 'Unknown Client Error' : 'Unknown Server Error',\n code: code,\n details: isClientError\n ? 'An unknown client error occurred.'\n : 'An unknown server error occurred.',\n };\n}\n","/**\n * HTTP Response Kit - System/socket error mapping\n *\n * Maps Node.js system errors (socket, DNS, timeout - including the undici\n * codes thrown by Node 18+ global `fetch`) to the semantically correct\n * 5xx HTTP status:\n *\n * - upstream refused / reset / unreachable -> 502 Bad Gateway\n * - upstream timed out -> 504 Gateway Timeout\n * - temporary local exhaustion / DNS retry -> 503 Service Unavailable\n *\n * These are NOT new HTTP statuses: socket errors are causes, and this module\n * translates them into the right response. Mapped errors are always\n * `expose: false` (the raw message stays on the instance for logging) and\n * carry the syscall code as `errorCode` for telemetry.\n *\n * @module errors/system-errors\n */\n\nimport { HttpError } from './HttpError';\n\n/**\n * Mapping from Node.js / undici error codes to HTTP status codes.\n * Exported so consumers can inspect or extend their own logic on top.\n */\nexport const SystemErrorStatusMap: Readonly<Record<string, number>> = Object.freeze({\n // Connection-level failures -> 502 Bad Gateway\n ECONNREFUSED: 502,\n ECONNRESET: 502,\n ECONNABORTED: 502,\n EPIPE: 502,\n EHOSTUNREACH: 502,\n ENETUNREACH: 502,\n ENETDOWN: 502,\n ENOTFOUND: 502, // DNS: host does not resolve\n EPROTO: 502, // TLS/protocol failure\n ERR_TLS_CERT_ALTNAME_INVALID: 502,\n\n // Timeouts -> 504 Gateway Timeout\n ETIMEDOUT: 504,\n ESOCKETTIMEDOUT: 504,\n\n // Temporary conditions -> 503 Service Unavailable\n EAI_AGAIN: 503, // DNS: temporary resolution failure\n EMFILE: 503, // too many open files (fd exhaustion)\n ENFILE: 503,\n ENOBUFS: 503,\n\n // undici / Node 18+ global fetch\n UND_ERR_CONNECT_TIMEOUT: 504,\n UND_ERR_HEADERS_TIMEOUT: 504,\n UND_ERR_BODY_TIMEOUT: 504,\n UND_ERR_SOCKET: 502,\n UND_ERR_DESTROYED: 502,\n UND_ERR_CLOSED: 502,\n});\n\n/** Max depth when searching the `cause` chain for a system error code */\nconst MAX_CAUSE_DEPTH = 5;\n\n/**\n * Extract a known system error code from an error, walking the `cause`\n * chain (Node's `fetch failed` TypeError carries the real code in `cause`).\n * @internal\n */\nexport function findSystemErrorCode(error: unknown): string | undefined {\n let current: unknown = error;\n let depth = 0;\n while (current !== null && typeof current === 'object' && depth < MAX_CAUSE_DEPTH) {\n const code = (current as { code?: unknown }).code;\n if (typeof code === 'string' && code in SystemErrorStatusMap) {\n return code;\n }\n current = (current as { cause?: unknown }).cause;\n depth++;\n }\n return undefined;\n}\n\n/**\n * Map a Node.js system/socket error to the appropriate HttpError\n * (502/503/504), or return `undefined` when the error is not a\n * recognized system error.\n *\n * The resulting error is never exposable: clients get the generic status\n * description, while the original message and cause stay available for\n * logging. The syscall code is set as `errorCode` for telemetry.\n *\n * @example\n * ```ts\n * try {\n * await fetch('http://upstream.internal/api');\n * } catch (err) {\n * throw mapSystemError(err) ?? HttpError.fromError(err);\n * }\n * // ECONNREFUSED -> 502 { error: { code: 'ECONNREFUSED', message: <generic> } }\n * ```\n */\nexport function mapSystemError(error: unknown): HttpError | undefined {\n const code = findSystemErrorCode(error);\n if (code === undefined) {\n return undefined;\n }\n\n const status = SystemErrorStatusMap[code];\n return new HttpError(status, {\n message: error instanceof Error ? error.message : String(error),\n cause: error instanceof Error ? error : undefined,\n expose: false,\n errorCode: code,\n });\n}\n","/**\n * HTTP Response Kit - HttpError Class\n * @module errors/HttpError\n */\n\nimport type { HttpErrorOptions, ProblemDetails, ProblemOptions, ValidationIssue } from '../types';\nimport { type HttpClientErrorCode, type HttpServerErrorCode } from '../constants/status-codes';\nimport { getErrorDefinition } from '../constants/error-definitions';\nimport { mapSystemError } from './system-errors';\n\n/**\n * Custom HTTP Error class that extends the native Error class.\n * Provides structured error information for HTTP responses.\n *\n * Security model: `expose` controls whether `message` may be sent to clients.\n * It defaults to `true` for 4xx and `false` for 5xx, so internal server error\n * messages are never leaked unless explicitly allowed. The full message is\n * always available on the instance for logging.\n *\n * @example\n * ```ts\n * // Basic usage with status code\n * throw new HttpError(404);\n * throw new HttpError(HttpErrorCode.NOT_FOUND);\n *\n * // With custom message\n * throw new HttpError(404, { message: 'User not found' });\n *\n * // With metadata + stable application code\n * throw new HttpError(400, {\n * message: 'Validation failed',\n * errorCode: 'VALIDATION_FAILED',\n * metadata: { fields: ['email', 'password'] }\n * });\n *\n * // Using factory methods\n * throw HttpError.notFound('Resource not found');\n * throw HttpError.validation([{ field: 'email', message: 'Invalid email' }]);\n * ```\n */\nexport class HttpError extends Error {\n /** HTTP status code */\n readonly code: number;\n\n /** Lowercase error type identifier */\n readonly type: string;\n\n /** Human-readable error title */\n readonly title: string;\n\n /** Default error description from definition */\n readonly details: string;\n\n /** Additional error metadata */\n readonly metadata?: Record<string, unknown>;\n\n /** Original error cause (also available as native `Error.cause`) */\n readonly cause?: Error;\n\n /** Retry-after time in seconds (if applicable) */\n readonly retryAfter?: number;\n\n /** Whether `message` is safe to send to clients (4xx: true, 5xx: false by default) */\n readonly expose: boolean;\n\n /** Stable application-level error code (e.g. \"USER_NOT_FOUND\") */\n readonly errorCode?: string;\n\n /** Structured validation issues */\n readonly validationErrors?: ValidationIssue[];\n\n /** Extra HTTP headers associated with this error */\n readonly headers?: Record<string, string>;\n\n /** RFC 9457 `instance` URI for this specific occurrence */\n readonly instance?: string;\n\n /**\n * Creates a new HttpError instance\n *\n * @param code - HTTP status code (e.g., 404, 500)\n * @param options - Optional configuration\n */\n constructor(code: HttpClientErrorCode | HttpServerErrorCode | number, options: HttpErrorOptions = {}) {\n const errorInfo = getErrorDefinition(code);\n const finalMessage = options.message ?? errorInfo.details;\n\n super(finalMessage);\n\n this.name = 'HttpError';\n this.code = errorInfo.code;\n this.type = errorInfo.type;\n this.title = errorInfo.title;\n this.details = errorInfo.details;\n this.metadata = options.metadata;\n this.retryAfter = options.retryAfter ?? errorInfo.retryAfter;\n this.expose = options.expose ?? errorInfo.code < 500;\n this.errorCode = options.errorCode;\n this.validationErrors = options.validationErrors;\n this.headers = options.headers;\n this.instance = options.instance;\n\n // Native ES2022 error cause + typed accessor\n if (options.cause !== undefined) {\n this.cause = options.cause;\n }\n\n // Maintains proper stack trace for where error was thrown\n if (typeof (Error as any).captureStackTrace === 'function') {\n (Error as any).captureStackTrace(this, HttpError);\n }\n }\n\n /**\n * The message that is safe to send to clients.\n * Falls back to the generic definition message when `expose` is false.\n */\n get safeMessage(): string {\n return this.expose ? this.message : this.details;\n }\n\n /**\n * HTTP headers that should accompany this error response\n * (e.g. `Retry-After` for 429/503, plus any custom headers).\n */\n getHeaders(): Record<string, string> {\n const headers: Record<string, string> = { ...this.headers };\n if (this.retryAfter !== undefined) {\n headers['Retry-After'] = String(this.retryAfter);\n }\n return headers;\n }\n\n /**\n * Convert error to plain object for JSON serialization.\n * Note: contains the full (non-sanitized) message - intended for logging.\n * Use `kit.error()` / `toProblemDetails()` for client output.\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n code: this.code,\n type: this.type,\n title: this.title,\n message: this.message,\n details: this.details,\n errorCode: this.errorCode,\n metadata: this.metadata,\n retryAfter: this.retryAfter,\n expose: this.expose,\n validationErrors: this.validationErrors,\n };\n }\n\n /**\n * Build an RFC 9457 Problem Details object for this error.\n * Serve it with `Content-Type: application/problem+json`.\n *\n * @example\n * ```ts\n * const problem = HttpError.notFound('User not found').toProblemDetails({\n * typeBase: 'https://errors.example.com',\n * instance: '/users/42',\n * });\n * // { type: 'https://errors.example.com/not_found', title: 'Not Found',\n * // status: 404, detail: 'User not found', instance: '/users/42' }\n * ```\n */\n toProblemDetails(options: ProblemOptions = {}): ProblemDetails {\n const exposed = options.expose ?? this.expose;\n const problem: ProblemDetails = {\n type: options.typeBase\n ? `${options.typeBase.replace(/\\/$/, '')}/${this.type}`\n : 'about:blank',\n title: this.title,\n status: this.code,\n detail: exposed ? this.message : this.details,\n };\n\n if (options.instance ?? this.instance) {\n problem.instance = options.instance ?? this.instance;\n }\n if (this.errorCode) {\n problem.code = this.errorCode;\n }\n if (this.validationErrors?.length) {\n problem.errors = this.validationErrors;\n }\n if (options.requestId) {\n problem.request_id = options.requestId;\n }\n if (options.extensions) {\n for (const [key, value] of Object.entries(options.extensions)) {\n if (!(key in problem)) {\n problem[key] = value;\n }\n }\n }\n\n return problem;\n }\n\n // ========================================================================\n // Factory Methods - 4xx Client Errors\n // ========================================================================\n\n /** 400 Bad Request */\n static badRequest(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(400, { message, metadata });\n }\n\n /** 401 Unauthorized */\n static unauthorized(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(401, { message, metadata });\n }\n\n /** 402 Payment Required */\n static paymentRequired(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(402, { message, metadata });\n }\n\n /** 403 Forbidden */\n static forbidden(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(403, { message, metadata });\n }\n\n /** 404 Not Found */\n static notFound(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(404, { message, metadata });\n }\n\n /** 405 Method Not Allowed */\n static methodNotAllowed(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(405, { message, metadata });\n }\n\n /** 406 Not Acceptable */\n static notAcceptable(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(406, { message, metadata });\n }\n\n /** 407 Proxy Authentication Required */\n static proxyAuthenticationRequired(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(407, { message, metadata });\n }\n\n /** 408 Request Timeout */\n static requestTimeout(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(408, { message, metadata });\n }\n\n /** 409 Conflict */\n static conflict(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(409, { message, metadata });\n }\n\n /** 410 Gone */\n static gone(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(410, { message, metadata });\n }\n\n /** 411 Length Required */\n static lengthRequired(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(411, { message, metadata });\n }\n\n /** 412 Precondition Failed */\n static preconditionFailed(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(412, { message, metadata });\n }\n\n /** 413 Payload Too Large */\n static payloadTooLarge(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(413, { message, metadata });\n }\n\n /** 414 URI Too Long */\n static uriTooLong(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(414, { message, metadata });\n }\n\n /** 415 Unsupported Media Type */\n static unsupportedMediaType(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(415, { message, metadata });\n }\n\n /** 416 Range Not Satisfiable */\n static rangeNotSatisfiable(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(416, { message, metadata });\n }\n\n /** 417 Expectation Failed */\n static expectationFailed(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(417, { message, metadata });\n }\n\n /** 418 I'm a Teapot */\n static imATeapot(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(418, { message, metadata });\n }\n\n /** 421 Misdirected Request */\n static misdirectedRequest(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(421, { message, metadata });\n }\n\n /** 422 Unprocessable Entity */\n static unprocessableEntity(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(422, { message, metadata });\n }\n\n /**\n * 422 Unprocessable Entity with structured validation issues.\n *\n * @example\n * ```ts\n * throw HttpError.validation([\n * { field: 'email', message: 'Invalid email format', code: 'invalid_format' },\n * { field: 'age', message: 'Must be >= 18', code: 'too_small' },\n * ]);\n * ```\n */\n static validation(\n errors: ValidationIssue[],\n message = 'Validation failed',\n code: number = 422\n ): HttpError {\n return new HttpError(code, { message, validationErrors: errors, errorCode: 'VALIDATION_FAILED' });\n }\n\n /** 423 Locked */\n static locked(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(423, { message, metadata });\n }\n\n /** 424 Failed Dependency */\n static failedDependency(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(424, { message, metadata });\n }\n\n /** 425 Too Early */\n static tooEarly(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(425, { message, metadata });\n }\n\n /** 426 Upgrade Required */\n static upgradeRequired(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(426, { message, metadata });\n }\n\n /** 428 Precondition Required */\n static preconditionRequired(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(428, { message, metadata });\n }\n\n /** 429 Too Many Requests */\n static tooManyRequests(message?: string, retryAfter?: number, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(429, { message, metadata, retryAfter });\n }\n\n /** 431 Request Header Fields Too Large */\n static requestHeaderFieldsTooLarge(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(431, { message, metadata });\n }\n\n /** 451 Unavailable For Legal Reasons */\n static unavailableForLegalReasons(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(451, { message, metadata });\n }\n\n // ========================================================================\n // Factory Methods - 5xx Server Errors\n // ========================================================================\n\n /** 500 Internal Server Error */\n static internalServerError(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(500, { message, metadata });\n }\n\n /** 501 Not Implemented */\n static notImplemented(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(501, { message, metadata });\n }\n\n /** 502 Bad Gateway */\n static badGateway(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(502, { message, metadata });\n }\n\n /** 503 Service Unavailable */\n static serviceUnavailable(message?: string, retryAfter?: number, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(503, { message, metadata, retryAfter });\n }\n\n /** 504 Gateway Timeout */\n static gatewayTimeout(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(504, { message, metadata });\n }\n\n /** 505 HTTP Version Not Supported */\n static httpVersionNotSupported(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(505, { message, metadata });\n }\n\n /** 506 Variant Also Negotiates */\n static variantAlsoNegotiates(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(506, { message, metadata });\n }\n\n /** 507 Insufficient Storage */\n static insufficientStorage(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(507, { message, metadata });\n }\n\n /** 508 Loop Detected */\n static loopDetected(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(508, { message, metadata });\n }\n\n /** 509 Bandwidth Limit Exceeded */\n static bandwidthLimitExceeded(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(509, { message, metadata });\n }\n\n /** 510 Not Extended */\n static notExtended(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(510, { message, metadata });\n }\n\n /** 511 Network Authentication Required */\n static networkAuthenticationRequired(message?: string, metadata?: Record<string, unknown>): HttpError {\n return new HttpError(511, { message, metadata });\n }\n\n // ========================================================================\n // Utility Methods\n // ========================================================================\n\n /**\n * Create an HttpError from an unknown error.\n *\n * Security: wrapped errors are marked `expose: false` when the resulting\n * status is 5xx, so unexpected internal messages (DB errors, stack info,\n * connection strings...) are never sent to clients. The original message\n * and cause are preserved on the instance for logging.\n *\n * System/socket errors (ECONNREFUSED, ETIMEDOUT, undici fetch codes...)\n * are automatically mapped to the semantically correct 502/503/504 -\n * including codes buried in the `cause` chain (e.g. Node's\n * `fetch failed` TypeError) - with the syscall code as `errorCode`.\n */\n static fromError(error: unknown, fallbackCode = 500): HttpError {\n if (error instanceof HttpError) {\n return error;\n }\n\n if (fallbackCode < 400 || fallbackCode > 599) {\n throw new RangeError(\n `fallbackCode must be between 400 and 599, got ${fallbackCode}`\n );\n }\n\n // Recognized system/socket errors win over the generic fallback:\n // they carry more precise gateway semantics (502/503/504).\n const systemError = mapSystemError(error);\n if (systemError !== undefined) {\n return systemError;\n }\n\n if (error instanceof Error) {\n return new HttpError(fallbackCode, {\n message: error.message,\n cause: error,\n expose: fallbackCode < 500,\n });\n }\n\n return new HttpError(fallbackCode, {\n message: String(error),\n expose: fallbackCode < 500,\n });\n }\n\n /**\n * Check if an error is an HttpError\n */\n static isHttpError(error: unknown): error is HttpError {\n return error instanceof HttpError;\n }\n\n /**\n * Check if error is a client error (4xx)\n */\n isClientError(): boolean {\n return this.code >= 400 && this.code < 500;\n }\n\n /**\n * Check if error is a server error (5xx)\n */\n isServerError(): boolean {\n return this.code >= 500 && this.code < 600;\n }\n\n /**\n * Flattened chain of cause messages (most recent first).\n * Useful for structured logging; never serialized to clients in production.\n */\n getCauseChain(): string[] {\n const chain: string[] = [];\n let current: unknown = this.cause;\n let depth = 0;\n while (current instanceof Error && depth < 10) {\n chain.push(`${current.name}: ${current.message}`);\n current = (current as { cause?: unknown }).cause;\n depth++;\n }\n return chain;\n }\n}\n","/**\n * HTTP Response Kit - Success Definitions\n * @module constants/success-definitions\n */\n\nimport type { HttpSuccessInfo } from '../types';\nimport { HttpSuccessCode, HttpRedirectCode, HttpInfoCode } from './status-codes';\n\n/**\n * Complete definitions for HTTP 2xx Success codes\n */\nexport const HttpSuccessDefinitions: Record<number, HttpSuccessInfo> = {\n [HttpSuccessCode.OK]: {\n code: 200,\n description: 'The request has succeeded.',\n },\n\n [HttpSuccessCode.CREATED]: {\n code: 201,\n description: 'The request has been fulfilled and resulted in a new resource being created.',\n },\n\n [HttpSuccessCode.ACCEPTED]: {\n code: 202,\n description: 'The request has been accepted for processing, but the processing has not been completed.',\n },\n\n [HttpSuccessCode.NON_AUTHORITATIVE_INFORMATION]: {\n code: 203,\n description: 'The returned meta-information is from a local or third-party copy.',\n },\n\n [HttpSuccessCode.NO_CONTENT]: {\n code: 204,\n description: 'The server successfully processed the request and is not returning any content.',\n },\n\n [HttpSuccessCode.RESET_CONTENT]: {\n code: 205,\n description: 'The server successfully processed the request and requires the requester to reset the document view.',\n },\n\n [HttpSuccessCode.PARTIAL_CONTENT]: {\n code: 206,\n description: 'The server is delivering only part of the resource due to a range header sent by the client.',\n },\n\n [HttpSuccessCode.MULTI_STATUS]: {\n code: 207,\n description: 'The message body contains multiple status codes for multiple independent operations.',\n },\n\n [HttpSuccessCode.ALREADY_REPORTED]: {\n code: 208,\n description: 'The members of a DAV binding have already been enumerated in a preceding part of the response.',\n },\n\n [HttpSuccessCode.IM_USED]: {\n code: 226,\n description: 'The server has fulfilled a GET request and the response is a representation of the result of one or more instance-manipulations.',\n },\n} as const;\n\nObject.freeze(HttpSuccessDefinitions);\n\n/**\n * Complete definitions for HTTP 3xx Redirect codes\n */\nexport const HttpRedirectDefinitions: Record<number, HttpSuccessInfo> = {\n [HttpRedirectCode.MULTIPLE_CHOICES]: {\n code: 300,\n description: 'The request has more than one possible response.',\n },\n\n [HttpRedirectCode.MOVED_PERMANENTLY]: {\n code: 301,\n description: 'The URL of the requested resource has been changed permanently.',\n },\n\n [HttpRedirectCode.FOUND]: {\n code: 302,\n description: 'The URI of the requested resource has been changed temporarily.',\n },\n\n [HttpRedirectCode.SEE_OTHER]: {\n code: 303,\n description: 'The response can be found under another URI using the GET method.',\n },\n\n [HttpRedirectCode.NOT_MODIFIED]: {\n code: 304,\n description: 'The resource has not been modified since the version specified by the request headers.',\n },\n\n [HttpRedirectCode.USE_PROXY]: {\n code: 305,\n description: 'The requested resource must be accessed through the proxy.',\n },\n\n [HttpRedirectCode.TEMPORARY_REDIRECT]: {\n code: 307,\n description: 'The request should be repeated with another URI but future requests should use the original URI.',\n },\n\n [HttpRedirectCode.PERMANENT_REDIRECT]: {\n code: 308,\n description: 'The request and all future requests should be repeated using another URI.',\n },\n} as const;\n\nObject.freeze(HttpRedirectDefinitions);\n\n/**\n * Complete definitions for HTTP 1xx Informational codes\n */\nexport const HttpInfoDefinitions: Record<number, HttpSuccessInfo> = {\n [HttpInfoCode.CONTINUE]: {\n code: 100,\n description: 'The initial part of a request has been received and has not yet been rejected by the server.',\n },\n\n [HttpInfoCode.SWITCHING_PROTOCOLS]: {\n code: 101,\n description: 'The server is switching protocols as requested by the client.',\n },\n\n [HttpInfoCode.PROCESSING]: {\n code: 102,\n description: 'The server has received and is processing the request, but no response is available yet.',\n },\n\n [HttpInfoCode.EARLY_HINTS]: {\n code: 103,\n description: 'The server is sending some response headers before the final response.',\n },\n} as const;\n\nObject.freeze(HttpInfoDefinitions);\n\n/**\n * Get success definition by status code\n */\nexport function getSuccessDefinition(code: number): HttpSuccessInfo {\n const definedInfo =\n HttpSuccessDefinitions[code] ||\n HttpRedirectDefinitions[code] ||\n HttpInfoDefinitions[code];\n\n if (definedInfo) {\n return definedInfo;\n }\n\n // Preserve the original code but provide a generic fallback definition\n return {\n code: code,\n description: 'The request was processed with a non-standard status code.',\n };\n}\n","/**\n * HTTP Response Kit - ResponseKit\n *\n * The single, definitive way to format responses: create an isolated kit\n * with `createResponseKit()`. Every kit owns its configuration - there is\n * no global mutable state anywhere in this library.\n *\n * @module kit\n */\n\nimport type {\n SuccessResponseConfig,\n ErrorResponseConfig,\n SuccessResponse,\n ErrorResponse,\n PaginationInput,\n CursorPaginationInput,\n KitConfig,\n ProblemDetails,\n ProblemOptions,\n} from './types';\nimport { HttpError } from './errors/HttpError';\nimport { getSuccessDefinition } from './constants/success-definitions';\nimport { HttpSuccessCode, HttpRedirectCode } from './constants/status-codes';\n\n/** Convert a snake_case key to camelCase */\nfunction snakeToCamel(key: string): string {\n return key.replace(/_([a-z])/g, (_, c: string) => c.toUpperCase());\n}\n\n/** Shallow-convert response keys to camelCase (plus pagination metadata) */\nfunction camelizeResponse<R extends Record<string, unknown>>(response: R): R {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(response)) {\n out[snakeToCamel(key)] = value;\n }\n const metadata = out.metadata as Record<string, unknown> | undefined;\n if (metadata && typeof metadata === 'object' && metadata.pagination && typeof metadata.pagination === 'object') {\n const pagination: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(metadata.pagination as Record<string, unknown>)) {\n pagination[snakeToCamel(key)] = value;\n }\n out.metadata = { ...metadata, pagination };\n }\n return out as R;\n}\n\n/** Type guard: is this a success response? */\nexport function isSuccessResponse(response: SuccessResponse | ErrorResponse): response is SuccessResponse {\n return response.success === true;\n}\n\n/** Type guard: is this an error response? */\nexport function isErrorResponse(response: SuccessResponse | ErrorResponse): response is ErrorResponse {\n return response.success === false;\n}\n\n/**\n * An isolated response formatter with its own configuration.\n * Create one with {@link createResponseKit}.\n */\nexport class ResponseKit {\n private readonly config: KitConfig;\n\n constructor(config: KitConfig = {}) {\n this.config = {\n includeTimestamp: true,\n format: 'standard',\n casing: 'snake',\n exposeServerErrors: false,\n ...config,\n customMessages: { ...config.customMessages },\n };\n }\n\n /** Merge partial configuration into this instance */\n configure(config: Partial<KitConfig>): void {\n Object.assign(this.config, {\n ...config,\n customMessages: { ...this.config.customMessages, ...config.customMessages },\n });\n }\n\n /** Snapshot of the current configuration */\n getConfig(): Readonly<KitConfig> {\n return { ...this.config };\n }\n\n /** Whether dev mode is active (stack traces, cause chains) */\n isDevelopment(): boolean {\n return this.config.isDevelopment ?? process.env.NODE_ENV === 'development';\n }\n\n private finalize<R extends Record<string, unknown>>(response: R): R {\n let out: R = this.config.casing === 'camel' ? camelizeResponse(response) : response;\n const transformer = this.config.responseTransformer;\n if (transformer) {\n out = transformer(out) as R;\n }\n return out;\n }\n\n /**\n * Resolve the outgoing client-facing message for an error.\n *\n * Priority: messageResolver > explicit message (if exposed)\n * > customMessages[code] > generic status description.\n */\n private resolveMessage(error: HttpError, exposed: boolean): string {\n const resolved = this.config.messageResolver?.(error);\n if (resolved !== undefined) return resolved;\n\n const customDefault = this.config.customMessages?.[error.code];\n const hasExplicitMessage = error.message !== error.details;\n\n if (exposed && hasExplicitMessage) return error.message;\n return customDefault ?? error.details;\n }\n\n // ========================================================================\n // Success\n // ========================================================================\n\n /** Format a success response */\n success<T = unknown>(config: SuccessResponseConfig<T> = {}): SuccessResponse<T> {\n const { data, message, statusCode = HttpSuccessCode.OK, metadata = {}, requestId } = config;\n\n const successInfo = getSuccessDefinition(statusCode);\n\n const response: SuccessResponse<T> = {\n success: true,\n status_code: successInfo.code,\n };\n\n if (this.config.includeTimestamp ?? true) {\n response.timestamp = new Date().toISOString();\n }\n\n if (requestId) {\n response.request_id = requestId;\n }\n\n // Don't include data for 204 No Content, 205 Reset Content, and 304 Not Modified\n if (\n statusCode !== HttpSuccessCode.NO_CONTENT &&\n statusCode !== HttpSuccessCode.RESET_CONTENT &&\n statusCode !== HttpRedirectCode.NOT_MODIFIED\n ) {\n if (data !== null && data !== undefined) {\n response.data = data;\n }\n }\n\n if (message) {\n response.message = message;\n }\n\n if (Object.keys(metadata).length > 0) {\n response.metadata = metadata;\n }\n\n return this.finalize(response);\n }\n\n // ========================================================================\n // Error\n // ========================================================================\n\n /**\n * Format an error response.\n *\n * Security: when the error is not exposable (5xx by default), the outgoing\n * message falls back to the generic status description (or the configured\n * custom message for that code) and `metadata` is omitted. The original\n * message stays available on the error instance for logging.\n */\n error(error: HttpError, config: ErrorResponseConfig = {}): ErrorResponse {\n const { includeStack, additionalFields, requestId } = config;\n const cfg = this.config;\n\n const exposed =\n config.expose ??\n (error.expose || (error.isServerError() && cfg.exposeServerErrors === true));\n\n const response: ErrorResponse = {\n success: false,\n status_code: error.code,\n error: {\n type: error.type,\n title: error.title,\n message: this.resolveMessage(error, exposed),\n },\n };\n\n if (cfg.includeTimestamp ?? true) {\n response.timestamp = new Date().toISOString();\n }\n\n if (requestId) {\n response.request_id = requestId;\n }\n\n // Stable application-level error code\n if (error.errorCode) {\n response.error.code = error.errorCode;\n }\n\n // Include generic error details (always safe: comes from definitions)\n if (error.details) {\n response.error.details = error.details;\n }\n\n // Structured validation issues\n if (error.validationErrors?.length) {\n response.error.errors = error.validationErrors;\n }\n\n // Stack trace + cause chain in development mode only (separate fields)\n if (includeStack ?? this.isDevelopment()) {\n response.error.stack = error.stack;\n const causes = error.getCauseChain();\n if (causes.length > 0) {\n response.error.causes = causes;\n }\n }\n\n // Include retry-after if present\n if (error.retryAfter) {\n response.retry_after = error.retryAfter;\n }\n\n // Include metadata only when the error is exposable (may contain internals)\n if (error.metadata && exposed) {\n const sanitized = cfg.metadataSanitizer ? cfg.metadataSanitizer(error.metadata) : error.metadata;\n if (Object.keys(sanitized).length > 0) {\n response.metadata = sanitized;\n }\n }\n\n // Add any additional fields (protecting core structure)\n if (additionalFields) {\n const { success, status_code, error: _error, timestamp, metadata, retry_after, request_id, ...safeFields } = additionalFields;\n Object.assign(response, safeFields);\n }\n\n return this.finalize(response);\n }\n\n /** Format a response from any error (converts to HttpError first) */\n fromError(error: unknown, config: ErrorResponseConfig = {}): ErrorResponse {\n const httpError = HttpError.fromError(error, config.fallbackCode);\n return this.error(httpError, config);\n }\n\n /**\n * Build an RFC 9457 Problem Details body from any error.\n * Serve it with `Content-Type: application/problem+json`\n * (see `PROBLEM_CONTENT_TYPE`).\n */\n problem(error: unknown, options: ProblemOptions = {}): ProblemDetails {\n const httpError = HttpError.fromError(error);\n const exposed = options.expose ?? httpError.expose;\n const problem = httpError.toProblemDetails({\n typeBase: options.typeBase ?? this.config.problemTypeBase,\n ...options,\n });\n problem.detail = this.resolveMessage(httpError, exposed);\n return problem;\n }\n\n // ========================================================================\n // Convenience Methods\n // ========================================================================\n\n /** 200 OK */\n ok<T = unknown>(data?: T, message?: string): SuccessResponse<T> {\n return this.success<T>({ data, message, statusCode: HttpSuccessCode.OK });\n }\n\n /** 201 Created */\n created<T = unknown>(data?: T, message?: string): SuccessResponse<T> {\n return this.success<T>({ data, message, statusCode: HttpSuccessCode.CREATED });\n }\n\n /** 202 Accepted */\n accepted<T = unknown>(data?: T, message?: string): SuccessResponse<T> {\n return this.success<T>({ data, message, statusCode: HttpSuccessCode.ACCEPTED });\n }\n\n /** 204 No Content */\n noContent(): SuccessResponse<never> {\n return this.success<never>({ statusCode: HttpSuccessCode.NO_CONTENT });\n }\n\n /** 206 Partial Content */\n partialContent<T = unknown>(data?: T, message?: string): SuccessResponse<T> {\n return this.success<T>({ data, message, statusCode: HttpSuccessCode.PARTIAL_CONTENT });\n }\n\n /** 304 Not Modified */\n notModified(): SuccessResponse<never> {\n return this.success<never>({ statusCode: HttpRedirectCode.NOT_MODIFIED });\n }\n\n // ========================================================================\n // Pagination\n // ========================================================================\n\n /** Create an offset-based paginated success response */\n paginated<T = unknown>(data: T[], pagination: PaginationInput, message?: string): SuccessResponse<T[]> {\n const effectiveLimit = pagination.limit > 0 ? pagination.limit : 1;\n const totalPages = pagination.totalPages ?? Math.ceil(pagination.total / effectiveLimit);\n return this.success<T[]>({\n data,\n message,\n metadata: {\n pagination: {\n page: pagination.page,\n limit: effectiveLimit,\n total: pagination.total,\n total_pages: totalPages,\n has_next: pagination.page < totalPages,\n has_prev: pagination.page > 1,\n },\n },\n });\n }\n\n /**\n * Create a cursor-based paginated success response.\n *\n * @example\n * ```ts\n * kit.paginatedCursor(items, { nextCursor: 'eyJpZCI6NDJ9', limit: 20 });\n * // metadata.pagination: { next_cursor, limit, has_next: true, has_prev: false }\n * ```\n */\n paginatedCursor<T = unknown>(data: T[], cursor: CursorPaginationInput, message?: string): SuccessResponse<T[]> {\n const pagination: Record<string, unknown> = {\n has_next: cursor.nextCursor !== undefined && cursor.nextCursor !== null,\n has_prev: cursor.prevCursor !== undefined && cursor.prevCursor !== null,\n };\n if (cursor.nextCursor !== undefined) pagination.next_cursor = cursor.nextCursor;\n if (cursor.prevCursor !== undefined) pagination.prev_cursor = cursor.prevCursor;\n if (cursor.limit !== undefined) pagination.limit = cursor.limit;\n if (cursor.total !== undefined) pagination.total = cursor.total;\n\n return this.success<T[]>({ data, message, metadata: { pagination } });\n }\n}\n\n/**\n * Create an isolated ResponseKit instance with its own configuration.\n * This is the entry point of the library.\n *\n * @example\n * ```ts\n * const api = createResponseKit({\n * isDevelopment: process.env.NODE_ENV === 'development',\n * format: 'problem',\n * problemTypeBase: 'https://errors.example.com',\n * });\n *\n * api.ok(user);\n * api.error(HttpError.notFound('No such user'), { requestId: req.id });\n * ```\n */\nexport function createResponseKit(config: KitConfig = {}): ResponseKit {\n return new ResponseKit(config);\n}\n","/**\n * HTTP Response Kit - RFC 9457 Problem Details helpers\n * @module responses/problem\n */\n\nimport type { ProblemDetails, ProblemOptions } from '../types';\nimport { HttpError } from '../errors/HttpError';\n\n/**\n * The media type for RFC 9457 Problem Details responses.\n * Set it as `Content-Type` when sending problem bodies.\n */\nexport const PROBLEM_CONTENT_TYPE = 'application/problem+json';\n\n/**\n * Build an RFC 9457 Problem Details object from any error.\n *\n * @example\n * ```ts\n * res\n * .status(problem.status)\n * .set('Content-Type', PROBLEM_CONTENT_TYPE)\n * .json(toProblem(err, { typeBase: 'https://errors.example.com' }));\n * ```\n */\nexport function toProblem(error: unknown, options: ProblemOptions = {}): ProblemDetails {\n const httpError = HttpError.fromError(error);\n return httpError.toProblemDetails(options);\n}\n\n/**\n * Type guard for Problem Details objects\n */\nexport function isProblemDetails(value: unknown): value is ProblemDetails {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as ProblemDetails).title === 'string' &&\n typeof (value as ProblemDetails).status === 'number' &&\n typeof (value as ProblemDetails).type === 'string'\n );\n}\n","/**\n * HTTP Response Kit - Shared adapter internals\n * @module adapters/shared\n */\n\nimport type { ErrorResponse, ProblemDetails } from '../types';\nimport { HttpError } from '../errors/HttpError';\nimport { ResponseKit } from '../kit';\nimport { PROBLEM_CONTENT_TYPE } from '../responses/problem';\n\n/** Stateless fallback kit used when no kit is passed to an adapter */\nconst fallbackKit = new ResponseKit();\n\n/** Options shared by all framework adapters */\nexport interface AdapterOptions {\n /** Kit instance to use (default: an internal kit with default config) */\n kit?: ResponseKit;\n /** Request header carrying the correlation id (default: \"x-request-id\") */\n requestIdHeader?: string;\n /** Called with every handled error — hook your logger here */\n onError?: (error: HttpError, requestId?: string) => void;\n /** Override stack inclusion (default: kit dev mode) */\n includeStack?: boolean;\n /** Force RFC 9457 output regardless of kit `format` config */\n problem?: boolean;\n}\n\n/** Normalized payload ready to be sent by any framework */\nexport interface ErrorPayload {\n status: number;\n headers: Record<string, string>;\n contentType: string;\n body: ErrorResponse | ProblemDetails;\n error: HttpError;\n}\n\n/**\n * Convert any thrown value into a normalized, ready-to-send error payload.\n * @internal\n */\nexport function buildErrorPayload(\n err: unknown,\n requestId: string | undefined,\n options: AdapterOptions = {}\n): ErrorPayload {\n const kit = options.kit ?? fallbackKit;\n const error = HttpError.fromError(err);\n const useProblem = options.problem ?? kit.getConfig().format === 'problem';\n\n options.onError?.(error, requestId);\n\n const headers = error.getHeaders();\n\n if (useProblem) {\n return {\n status: error.code,\n headers,\n contentType: PROBLEM_CONTENT_TYPE,\n body: kit.problem(error, { requestId }),\n error,\n };\n }\n\n return {\n status: error.code,\n headers,\n contentType: 'application/json; charset=utf-8',\n body: kit.error(error, { requestId, includeStack: options.includeStack }),\n error,\n };\n}\n\n/** Extract a request id from a headers bag (string | string[] tolerant) */\nexport function extractRequestId(\n headers: Record<string, unknown> | undefined,\n headerName = 'x-request-id'\n): string | undefined {\n const value = headers?.[headerName] ?? headers?.[headerName.toLowerCase()];\n if (Array.isArray(value)) return typeof value[0] === 'string' ? value[0] : undefined;\n return typeof value === 'string' ? value : undefined;\n}\n","/**\n * HTTP Response Kit - Express adapter\n *\n * Zero-dependency (structural typing, no `@types/express` needed).\n *\n * @example\n * ```ts\n * import express from 'express';\n * import { errorHandler, notFoundHandler } from 'http-response-kit/express';\n *\n * const app = express();\n * // ...routes...\n * app.use(notFoundHandler());\n * app.use(errorHandler({ onError: (e, id) => logger.error({ err: e, requestId: id }) }));\n * ```\n *\n * @module adapters/express\n */\n\nimport { HttpError } from '../errors/HttpError';\nimport { buildErrorPayload, extractRequestId, type AdapterOptions } from './shared';\n\n/** Minimal structural view of an Express request */\nexport interface ExpressLikeRequest {\n headers?: Record<string, unknown>;\n method?: string;\n originalUrl?: string;\n url?: string;\n}\n\n/** Minimal structural view of an Express response */\nexport interface ExpressLikeResponse {\n headersSent?: boolean;\n status(code: number): ExpressLikeResponse;\n setHeader(name: string, value: string): unknown;\n json(body: unknown): unknown;\n}\n\nexport type ExpressErrorHandler = (\n err: unknown,\n req: ExpressLikeRequest,\n res: ExpressLikeResponse,\n next: (err?: unknown) => void\n) => void;\n\n/**\n * Express error-handling middleware. Register it LAST (after all routes).\n * Converts any thrown/forwarded error into a consistent JSON (or RFC 9457) body,\n * sets error headers (Retry-After, ...), and echoes the request id.\n */\nexport function errorHandler(options: AdapterOptions = {}): ExpressErrorHandler {\n return (err, req, res, next) => {\n if (res.headersSent) {\n next(err);\n return;\n }\n\n const requestId = extractRequestId(req.headers, options.requestIdHeader);\n const payload = buildErrorPayload(err, requestId, options);\n\n res.setHeader('Content-Type', payload.contentType);\n for (const [name, value] of Object.entries(payload.headers)) {\n res.setHeader(name, value);\n }\n\n res.status(payload.status).json(payload.body);\n };\n}\n\n/**\n * Express catch-all 404 middleware. Register it after all routes,\n * before `errorHandler()`.\n */\nexport function notFoundHandler(message?: string) {\n return (req: ExpressLikeRequest, _res: ExpressLikeResponse, next: (err?: unknown) => void): void => {\n next(HttpError.notFound(message ?? `Route ${req.method ?? ''} ${req.originalUrl ?? req.url ?? ''} not found`.trim()));\n };\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { extractRequestId, buildErrorPayload } from './chunk-FFRB2EUE.mjs';
2
+ import { HttpError } from './chunk-373JVXMN.mjs';
3
+
4
+ // src/adapters/express.ts
5
+ function errorHandler(options = {}) {
6
+ return (err, req, res, next) => {
7
+ if (res.headersSent) {
8
+ next(err);
9
+ return;
10
+ }
11
+ const requestId = extractRequestId(req.headers, options.requestIdHeader);
12
+ const payload = buildErrorPayload(err, requestId, options);
13
+ res.setHeader("Content-Type", payload.contentType);
14
+ for (const [name, value] of Object.entries(payload.headers)) {
15
+ res.setHeader(name, value);
16
+ }
17
+ res.status(payload.status).json(payload.body);
18
+ };
19
+ }
20
+ function notFoundHandler(message) {
21
+ return (req, _res, next) => {
22
+ next(HttpError.notFound(message ?? `Route ${req.method ?? ""} ${req.originalUrl ?? req.url ?? ""} not found`.trim()));
23
+ };
24
+ }
25
+
26
+ export { errorHandler, notFoundHandler };
27
+ //# sourceMappingURL=express.mjs.map
28
+ //# sourceMappingURL=express.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/express.ts"],"names":[],"mappings":";;;;AAkDO,SAAS,YAAA,CAAa,OAAA,GAA0B,EAAC,EAAwB;AAC5E,EAAA,OAAO,CAAC,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,IAAA,KAAS;AAC5B,IAAA,IAAI,IAAI,WAAA,EAAa;AACjB,MAAA,IAAA,CAAK,GAAG,CAAA;AACR,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,SAAA,GAAY,gBAAA,CAAiB,GAAA,CAAI,OAAA,EAAS,QAAQ,eAAe,CAAA;AACvE,IAAA,MAAM,OAAA,GAAU,iBAAA,CAAkB,GAAA,EAAK,SAAA,EAAW,OAAO,CAAA;AAEzD,IAAA,GAAA,CAAI,SAAA,CAAU,cAAA,EAAgB,OAAA,CAAQ,WAAW,CAAA;AACjD,IAAA,KAAA,MAAW,CAAC,MAAM,KAAK,CAAA,IAAK,OAAO,OAAA,CAAQ,OAAA,CAAQ,OAAO,CAAA,EAAG;AACzD,MAAA,GAAA,CAAI,SAAA,CAAU,MAAM,KAAK,CAAA;AAAA,IAC7B;AAEA,IAAA,GAAA,CAAI,OAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,IAAA,CAAK,QAAQ,IAAI,CAAA;AAAA,EAChD,CAAA;AACJ;AAMO,SAAS,gBAAgB,OAAA,EAAkB;AAC9C,EAAA,OAAO,CAAC,GAAA,EAAyB,IAAA,EAA2B,IAAA,KAAwC;AAChG,IAAA,IAAA,CAAK,UAAU,QAAA,CAAS,OAAA,IAAW,CAAA,MAAA,EAAS,GAAA,CAAI,UAAU,EAAE,CAAA,CAAA,EAAI,GAAA,CAAI,WAAA,IAAe,IAAI,GAAA,IAAO,EAAE,CAAA,UAAA,CAAA,CAAa,IAAA,EAAM,CAAC,CAAA;AAAA,EACxH,CAAA;AACJ","file":"express.mjs","sourcesContent":["/**\n * HTTP Response Kit - Express adapter\n *\n * Zero-dependency (structural typing, no `@types/express` needed).\n *\n * @example\n * ```ts\n * import express from 'express';\n * import { errorHandler, notFoundHandler } from 'http-response-kit/express';\n *\n * const app = express();\n * // ...routes...\n * app.use(notFoundHandler());\n * app.use(errorHandler({ onError: (e, id) => logger.error({ err: e, requestId: id }) }));\n * ```\n *\n * @module adapters/express\n */\n\nimport { HttpError } from '../errors/HttpError';\nimport { buildErrorPayload, extractRequestId, type AdapterOptions } from './shared';\n\n/** Minimal structural view of an Express request */\nexport interface ExpressLikeRequest {\n headers?: Record<string, unknown>;\n method?: string;\n originalUrl?: string;\n url?: string;\n}\n\n/** Minimal structural view of an Express response */\nexport interface ExpressLikeResponse {\n headersSent?: boolean;\n status(code: number): ExpressLikeResponse;\n setHeader(name: string, value: string): unknown;\n json(body: unknown): unknown;\n}\n\nexport type ExpressErrorHandler = (\n err: unknown,\n req: ExpressLikeRequest,\n res: ExpressLikeResponse,\n next: (err?: unknown) => void\n) => void;\n\n/**\n * Express error-handling middleware. Register it LAST (after all routes).\n * Converts any thrown/forwarded error into a consistent JSON (or RFC 9457) body,\n * sets error headers (Retry-After, ...), and echoes the request id.\n */\nexport function errorHandler(options: AdapterOptions = {}): ExpressErrorHandler {\n return (err, req, res, next) => {\n if (res.headersSent) {\n next(err);\n return;\n }\n\n const requestId = extractRequestId(req.headers, options.requestIdHeader);\n const payload = buildErrorPayload(err, requestId, options);\n\n res.setHeader('Content-Type', payload.contentType);\n for (const [name, value] of Object.entries(payload.headers)) {\n res.setHeader(name, value);\n }\n\n res.status(payload.status).json(payload.body);\n };\n}\n\n/**\n * Express catch-all 404 middleware. Register it after all routes,\n * before `errorHandler()`.\n */\nexport function notFoundHandler(message?: string) {\n return (req: ExpressLikeRequest, _res: ExpressLikeResponse, next: (err?: unknown) => void): void => {\n next(HttpError.notFound(message ?? `Route ${req.method ?? ''} ${req.originalUrl ?? req.url ?? ''} not found`.trim()));\n };\n}\n"]}
@@ -0,0 +1,45 @@
1
+ import { A as AdapterOptions } from './shared-DYq1Fic4.mjs';
2
+ import './kit-nHfihlKE.mjs';
3
+
4
+ /**
5
+ * HTTP Response Kit - Fastify adapter
6
+ *
7
+ * Zero-dependency (structural typing, no `fastify` types needed).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import Fastify from 'fastify';
12
+ * import { fastifyErrorHandler, fastifyNotFoundHandler } from 'http-response-kit/fastify';
13
+ *
14
+ * const app = Fastify();
15
+ * app.setErrorHandler(fastifyErrorHandler());
16
+ * app.setNotFoundHandler(fastifyNotFoundHandler());
17
+ * ```
18
+ *
19
+ * @module adapters/fastify
20
+ */
21
+
22
+ /** Minimal structural view of a Fastify request */
23
+ interface FastifyLikeRequest {
24
+ headers?: Record<string, unknown>;
25
+ method?: string;
26
+ url?: string;
27
+ /** Fastify's own request id */
28
+ id?: string | number;
29
+ }
30
+ /** Minimal structural view of a Fastify reply */
31
+ interface FastifyLikeReply {
32
+ status(code: number): FastifyLikeReply;
33
+ header(name: string, value: string): FastifyLikeReply;
34
+ send(body: unknown): unknown;
35
+ }
36
+ /**
37
+ * Fastify error handler. Converts every error (including Fastify's AJV
38
+ * validation errors, mapped to structured `error.errors`) into a consistent
39
+ * JSON (or RFC 9457) body.
40
+ */
41
+ declare function fastifyErrorHandler(options?: AdapterOptions): (error: unknown, request: FastifyLikeRequest, reply: FastifyLikeReply) => void;
42
+ /** Fastify not-found handler producing a consistent 404 body */
43
+ declare function fastifyNotFoundHandler(options?: AdapterOptions): (request: FastifyLikeRequest, reply: FastifyLikeReply) => void;
44
+
45
+ export { type FastifyLikeReply, type FastifyLikeRequest, fastifyErrorHandler, fastifyNotFoundHandler };
@@ -0,0 +1,45 @@
1
+ import { A as AdapterOptions } from './shared-Czwmz6Xa.js';
2
+ import './kit-nHfihlKE.js';
3
+
4
+ /**
5
+ * HTTP Response Kit - Fastify adapter
6
+ *
7
+ * Zero-dependency (structural typing, no `fastify` types needed).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import Fastify from 'fastify';
12
+ * import { fastifyErrorHandler, fastifyNotFoundHandler } from 'http-response-kit/fastify';
13
+ *
14
+ * const app = Fastify();
15
+ * app.setErrorHandler(fastifyErrorHandler());
16
+ * app.setNotFoundHandler(fastifyNotFoundHandler());
17
+ * ```
18
+ *
19
+ * @module adapters/fastify
20
+ */
21
+
22
+ /** Minimal structural view of a Fastify request */
23
+ interface FastifyLikeRequest {
24
+ headers?: Record<string, unknown>;
25
+ method?: string;
26
+ url?: string;
27
+ /** Fastify's own request id */
28
+ id?: string | number;
29
+ }
30
+ /** Minimal structural view of a Fastify reply */
31
+ interface FastifyLikeReply {
32
+ status(code: number): FastifyLikeReply;
33
+ header(name: string, value: string): FastifyLikeReply;
34
+ send(body: unknown): unknown;
35
+ }
36
+ /**
37
+ * Fastify error handler. Converts every error (including Fastify's AJV
38
+ * validation errors, mapped to structured `error.errors`) into a consistent
39
+ * JSON (or RFC 9457) body.
40
+ */
41
+ declare function fastifyErrorHandler(options?: AdapterOptions): (error: unknown, request: FastifyLikeRequest, reply: FastifyLikeReply) => void;
42
+ /** Fastify not-found handler producing a consistent 404 body */
43
+ declare function fastifyNotFoundHandler(options?: AdapterOptions): (request: FastifyLikeRequest, reply: FastifyLikeReply) => void;
44
+
45
+ export { type FastifyLikeReply, type FastifyLikeRequest, fastifyErrorHandler, fastifyNotFoundHandler };