{"version":3,"sources":["../src/index.ts","../src/statusCodes.ts","../src/error.ts"],"sourcesContent":["import Layer from \"express/lib/router/layer\";\nimport Router from \"express/lib/router\";\n\n/**\n * Gets the last element of an array.\n * @template T\n * @param {T[]} [arr=[]] - The array to get the last element from\n * @returns {T | undefined} The last element of the array or undefined if array is empty\n * @private\n */\nconst last = <T>(arr: T[] = []): T | undefined => arr[arr.length - 1];\n\n/**\n * No-op function used as fallback for error handling.\n * @type {Function}\n * @private\n */\nconst noop = Function.prototype as (...args: any[]) => void;\n\n/**\n * Copies properties from one function to another.\n * Used to preserve function properties when wrapping functions.\n * \n * @template T\n * @param {T} oldFn - The original function\n * @param {T} newFn - The new function to copy properties to\n * @returns {T} The new function with copied properties\n * @private\n */\nfunction copyFnProps<T extends Function>(oldFn: T, newFn: T): T {\n  Object.keys(oldFn).forEach((key) => {\n    (newFn as any)[key] = (oldFn as any)[key];\n  });\n  return newFn;\n}\n\n/**\n * Wraps an Express route handler to catch promise rejections and async errors.\n * If the handler returns a promise, any rejections are passed to Express's next() error handler.\n * This enables proper error handling in async route handlers.\n * \n * @template T\n * @param {T} fn - The route handler function to wrap\n * @returns {T} A wrapped version of the function that catches promise rejections\n * \n * @example\n * // Automatically catches errors in async handlers\n * app.get('/user/:id', wrap(async (req, res, next) => {\n *   const user = await User.findById(req.params.id);\n *   res.json(user);\n * }));\n * @private\n */\nfunction wrap<T extends Function>(fn: T): T {\n  const newFn = function newFn(this: any, ...args: any[]) {\n    const ret = fn.apply(this, args);\n    const next = (args.length === 5 ? args[2] : last(args)) || noop;\n    if (ret && ret.catch) ret.catch((err: any) => next(err));\n    return ret;\n  };\n  Object.defineProperty(newFn, \"length\", {\n    value: fn.length,\n    writable: false,\n  });\n  return copyFnProps(fn, newFn as unknown as T);\n}\n\n/**\n * Patches Express Router.param to automatically wrap param handlers.\n * This ensures async param handlers properly catch errors.\n * \n * @private\n */\nfunction patchRouterParam() {\n  const originalParam = Router.prototype.constructor.param;\n  Router.prototype.constructor.param = function param(\n    name: string,\n    fn: Function\n  ) {\n    fn = wrap(fn);\n    return originalParam.call(this, name, fn);\n  };\n}\n\n/**\n * Patches Express Layer.prototype to wrap route handlers with error catching.\n * This enables async/await route handlers to properly propagate errors to the error handler middleware.\n * When a route handler is set, it's automatically wrapped to catch promise rejections.\n */\nObject.defineProperty(Layer.prototype, \"handle\", {\n  enumerable: true,\n  get() {\n    return (this as any).__handle;\n  },\n  set(fn: Function) {\n    fn = wrap(fn);\n    (this as any).__handle = fn;\n  },\n});\n\n/**\n * Initialize error handling patches for Express.\n * This patches the Express Router to wrap async handlers and properly catch errors.\n */\npatchRouterParam();\n\nexport * from \"./error\";\nexport * from \"./statusCodes\";\n","/**\n * HTTP Status Codes constant object.\n * Contains all standard HTTP status codes organized by category:\n * - 1xx: Informational responses\n * - 2xx: Successful responses\n * - 3xx: Redirection messages\n * - 4xx: Client error responses\n * - 5xx: Server error responses\n * \n * @type {Object}\n * @readonly\n * \n * @example\n * import { HttpStatusCodes } from './statusCodes';\n * \n * if (response.statusCode === HttpStatusCodes.NOT_FOUND) {\n *   console.log('Resource not found');\n * }\n */\nexport const HttpStatusCodes = {\n  // 1xx Informational\n  /** 100 Continue - Client should continue sending the request body */\n  CONTINUE: 100,\n  /** 101 Switching Protocols - Server is switching to a different protocol */\n  SWITCHING_PROTOCOLS: 101,\n  /** 102 Processing - Server received the request and is processing it */\n  PROCESSING: 102,\n  /** 103 Early Hints - Early hints for preloading resources */\n  EARLY_HINTS: 103,\n\n  // 2xx Success\n  /** 200 OK - Request succeeded */\n  OK: 200,\n  /** 201 Created - Request succeeded and a new resource was created */\n  CREATED: 201,\n  /** 202 Accepted - Request has been accepted for processing but not completed */\n  ACCEPTED: 202,\n  /** 203 Non-Authoritative Information - Request succeeded but content is from another source */\n  NON_AUTHORITATIVE_INFORMATION: 203,\n  /** 204 No Content - Request succeeded but there's no content to send */\n  NO_CONTENT: 204,\n  /** 205 Reset Content - Request succeeded and client should reset the view */\n  RESET_CONTENT: 205,\n  /** 206 Partial Content - Server sent partial content per range request */\n  PARTIAL_CONTENT: 206,\n  /** 207 Multi-Status - Response contains multiple status codes */\n  MULTI_STATUS: 207,\n  /** 208 Already Reported - Members already reported in previous binding */\n  ALREADY_REPORTED: 208,\n  /** 226 IM Used - Instance manipulation resulted in this representation */\n  IM_USED: 226,\n\n  // 3xx Redirection\n  /** 300 Multiple Choices - Multiple options available for requested resource */\n  MULTIPLE_CHOICES: 300,\n  /** 301 Moved Permanently - Resource permanently moved to new URL */\n  MOVED_PERMANENTLY: 301,\n  /** 302 Found - Resource temporarily moved to different URL */\n  FOUND: 302,\n  /** 303 See Other - Request should be repeated with different method at specified URL */\n  SEE_OTHER: 303,\n  /** 304 Not Modified - Resource not modified since last request */\n  NOT_MODIFIED: 304,\n  /** 305 Use Proxy - Request must be made through proxy */\n  USE_PROXY: 305,\n  /** 307 Temporary Redirect - Resource temporarily moved, repeat request same method */\n  TEMPORARY_REDIRECT: 307,\n  /** 308 Permanent Redirect - Resource permanently moved, repeat request same method */\n  PERMANENT_REDIRECT: 308,\n\n  // 4xx Client Errors\n  /** 400 Bad Request - Request contains malformed syntax or invalid parameters */\n  BAD_REQUEST: 400,\n  /** 401 Unauthorized - Request requires authentication or invalid credentials */\n  UNAUTHORIZED: 401,\n  /** 402 Payment Required - Payment required for this resource */\n  PAYMENT_REQUIRED: 402,\n  /** 403 Forbidden - Client lacks permission to access the resource */\n  FORBIDDEN: 403,\n  /** 404 Not Found - Server cannot find the requested resource */\n  NOT_FOUND: 404,\n  /** 405 Method Not Allowed - HTTP method not allowed for this resource */\n  METHOD_NOT_ALLOWED: 405,\n  /** 406 Not Acceptable - Server cannot produce acceptable response format */\n  NOT_ACCEPTABLE: 406,\n  /** 407 Proxy Authentication Required - Proxy authentication required */\n  PROXY_AUTHENTICATION_REQUIRED: 407,\n  /** 408 Request Timeout - Server timed out waiting for request */\n  REQUEST_TIMEOUT: 408,\n  /** 409 Conflict - Request conflicts with current state of resource */\n  CONFLICT: 409,\n  /** 410 Gone - Requested resource no longer exists and won't be available again */\n  GONE: 410,\n  /** 411 Length Required - Request header Content-Length is required */\n  LENGTH_REQUIRED: 411,\n  /** 412 Precondition Failed - Precondition in request header not satisfied */\n  PRECONDITION_FAILED: 412,\n  /** 413 Payload Too Large - Request body exceeds maximum allowed size */\n  PAYLOAD_TOO_LARGE: 413,\n  /** 414 URI Too Long - Request URI exceeds maximum allowed length */\n  URI_TOO_LONG: 414,\n  /** 415 Unsupported Media Type - Request media type not supported */\n  UNSUPPORTED_MEDIA_TYPE: 415,\n  /** 416 Range Not Satisfiable - Range request cannot be satisfied */\n  RANGE_NOT_SATISFIABLE: 416,\n  /** 417 Expectation Failed - Server cannot meet Expect header requirements */\n  EXPECTATION_FAILED: 417,\n  /** 418 I'm a teapot - Server is a teapot (April Fools' joke) */\n  IM_A_TEAPOT: 418,\n  /** 421 Misdirected Request - Request sent to server that cannot produce response */\n  MISDIRECTED_REQUEST: 421,\n  /** 422 Unprocessable Entity - Request semantically incorrect or validation failed */\n  UNPROCESSABLE_ENTITY: 422,\n  /** 423 Locked - Resource being accessed is locked */\n  LOCKED: 423,\n  /** 424 Failed Dependency - Request failed due to failure of previous request */\n  FAILED_DEPENDENCY: 424,\n  /** 425 Too Early - Server unwilling to risk processing prematurely sent request */\n  TOO_EARLY: 425,\n  /** 426 Upgrade Required - Client should switch to different protocol */\n  UPGRADE_REQUIRED: 426,\n  /** 428 Precondition Required - Server requires conditional request */\n  PRECONDITION_REQUIRED: 428,\n  /** 429 Too Many Requests - Client sent too many requests (rate limited) */\n  TOO_MANY_REQUESTS: 429,\n  /** 431 Request Header Fields Too Large - Request header fields exceed size limit */\n  REQUEST_HEADER_FIELDS_TOO_LARGE: 431,\n  /** 451 Unavailable For Legal Reasons - Resource unavailable for legal reasons */\n  UNAVAILABLE_FOR_LEGAL_REASONS: 451,\n\n  // 5xx Server Errors\n  /** 500 Internal Server Error - Generic server error */\n  INTERNAL_SERVER_ERROR: 500,\n  /** 501 Not Implemented - Server does not support requested functionality */\n  NOT_IMPLEMENTED: 501,\n  /** 502 Bad Gateway - Server received invalid response from upstream server */\n  BAD_GATEWAY: 502,\n  /** 503 Service Unavailable - Server temporarily unable to handle requests */\n  SERVICE_UNAVAILABLE: 503,\n  /** 504 Gateway Timeout - Upstream server did not respond in time */\n  GATEWAY_TIMEOUT: 504,\n  /** 505 HTTP Version Not Supported - Server does not support HTTP version */\n  HTTP_VERSION_NOT_SUPPORTED: 505,\n  /** 506 Variant Also Negotiates - Server has internal configuration error */\n  VARIANT_ALSO_NEGOTIATES: 506,\n  /** 507 Insufficient Storage - Server unable to store request data */\n  INSUFFICIENT_STORAGE: 507,\n  /** 508 Loop Detected - Infinite loop detected in request processing */\n  LOOP_DETECTED: 508,\n  /** 510 Not Extended - Further extensions required to process request */\n  NOT_EXTENDED: 510,\n  /** 511 Network Authentication Required - Network authentication required */\n  NETWORK_AUTHENTICATION_REQUIRED: 511,\n} as const;\n\n/**\n * Default human-readable HTTP status messages mapped by status code.\n * Provides standard messages for each HTTP status code.\n * Can be used as fallback messages when no custom message is provided.\n * \n * @type {Object}\n * @readonly\n * \n * @example\n * import { DefaultStatusMessages, HttpStatusCodes } from './statusCodes';\n * \n * const message = DefaultStatusMessages[HttpStatusCodes.NOT_FOUND];\n * Result: 'Not Found'\n */\nexport const DefaultStatusMessages = {\n  // 1xx Informational\n  [HttpStatusCodes.CONTINUE]: \"Continue\",\n  [HttpStatusCodes.SWITCHING_PROTOCOLS]: \"Switching Protocols\",\n  [HttpStatusCodes.PROCESSING]: \"Processing\",\n  [HttpStatusCodes.EARLY_HINTS]: \"Early Hints\",\n\n  // 2xx Success\n  [HttpStatusCodes.OK]: \"OK\",\n  [HttpStatusCodes.CREATED]: \"Created\",\n  [HttpStatusCodes.ACCEPTED]: \"Accepted\",\n  [HttpStatusCodes.NON_AUTHORITATIVE_INFORMATION]:\n    \"Non-Authoritative Information\",\n  [HttpStatusCodes.NO_CONTENT]: \"No Content\",\n  [HttpStatusCodes.RESET_CONTENT]: \"Reset Content\",\n  [HttpStatusCodes.PARTIAL_CONTENT]: \"Partial Content\",\n  [HttpStatusCodes.MULTI_STATUS]: \"Multi-Status\",\n  [HttpStatusCodes.ALREADY_REPORTED]: \"Already Reported\",\n  [HttpStatusCodes.IM_USED]: \"IM Used\",\n\n  // 3xx Redirection\n  [HttpStatusCodes.MULTIPLE_CHOICES]: \"Multiple Choices\",\n  [HttpStatusCodes.MOVED_PERMANENTLY]: \"Moved Permanently\",\n  [HttpStatusCodes.FOUND]: \"Found\",\n  [HttpStatusCodes.SEE_OTHER]: \"See Other\",\n  [HttpStatusCodes.NOT_MODIFIED]: \"Not Modified\",\n  [HttpStatusCodes.USE_PROXY]: \"Use Proxy\",\n  [HttpStatusCodes.TEMPORARY_REDIRECT]: \"Temporary Redirect\",\n  [HttpStatusCodes.PERMANENT_REDIRECT]: \"Permanent Redirect\",\n\n  // 4xx Client Errors\n  [HttpStatusCodes.BAD_REQUEST]: \"Bad Request\",\n  [HttpStatusCodes.UNAUTHORIZED]: \"Unauthorized\",\n  [HttpStatusCodes.PAYMENT_REQUIRED]: \"Payment Required\",\n  [HttpStatusCodes.FORBIDDEN]: \"Forbidden\",\n  [HttpStatusCodes.NOT_FOUND]: \"Not Found\",\n  [HttpStatusCodes.METHOD_NOT_ALLOWED]: \"Method Not Allowed\",\n  [HttpStatusCodes.NOT_ACCEPTABLE]: \"Not Acceptable\",\n  [HttpStatusCodes.PROXY_AUTHENTICATION_REQUIRED]:\n    \"Proxy Authentication Required\",\n  [HttpStatusCodes.REQUEST_TIMEOUT]: \"Request Timeout\",\n  [HttpStatusCodes.CONFLICT]: \"Conflict\",\n  [HttpStatusCodes.GONE]: \"Gone\",\n  [HttpStatusCodes.LENGTH_REQUIRED]: \"Length Required\",\n  [HttpStatusCodes.PRECONDITION_FAILED]: \"Precondition Failed\",\n  [HttpStatusCodes.PAYLOAD_TOO_LARGE]: \"Payload Too Large\",\n  [HttpStatusCodes.URI_TOO_LONG]: \"URI Too Long\",\n  [HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE]: \"Unsupported Media Type\",\n  [HttpStatusCodes.RANGE_NOT_SATISFIABLE]: \"Range Not Satisfiable\",\n  [HttpStatusCodes.EXPECTATION_FAILED]: \"Expectation Failed\",\n  [HttpStatusCodes.IM_A_TEAPOT]: \"I'm a teapot\",\n  [HttpStatusCodes.MISDIRECTED_REQUEST]: \"Misdirected Request\",\n  [HttpStatusCodes.UNPROCESSABLE_ENTITY]: \"Unprocessable Entity\",\n  [HttpStatusCodes.LOCKED]: \"Locked\",\n  [HttpStatusCodes.FAILED_DEPENDENCY]: \"Failed Dependency\",\n  [HttpStatusCodes.TOO_EARLY]: \"Too Early\",\n  [HttpStatusCodes.UPGRADE_REQUIRED]: \"Upgrade Required\",\n  [HttpStatusCodes.PRECONDITION_REQUIRED]: \"Precondition Required\",\n  [HttpStatusCodes.TOO_MANY_REQUESTS]: \"Too Many Requests\",\n  [HttpStatusCodes.REQUEST_HEADER_FIELDS_TOO_LARGE]:\n    \"Request Header Fields Too Large\",\n  [HttpStatusCodes.UNAVAILABLE_FOR_LEGAL_REASONS]:\n    \"Unavailable For Legal Reasons\",\n\n  // 5xx Server Errors\n  [HttpStatusCodes.INTERNAL_SERVER_ERROR]: \"Internal Server Error\",\n  [HttpStatusCodes.NOT_IMPLEMENTED]: \"Not Implemented\",\n  [HttpStatusCodes.BAD_GATEWAY]: \"Bad Gateway\",\n  [HttpStatusCodes.SERVICE_UNAVAILABLE]: \"Service Unavailable\",\n  [HttpStatusCodes.GATEWAY_TIMEOUT]: \"Gateway Timeout\",\n  [HttpStatusCodes.HTTP_VERSION_NOT_SUPPORTED]: \"HTTP Version Not Supported\",\n  [HttpStatusCodes.VARIANT_ALSO_NEGOTIATES]: \"Variant Also Negotiates\",\n  [HttpStatusCodes.INSUFFICIENT_STORAGE]: \"Insufficient Storage\",\n  [HttpStatusCodes.LOOP_DETECTED]: \"Loop Detected\",\n  [HttpStatusCodes.NOT_EXTENDED]: \"Not Extended\",\n  [HttpStatusCodes.NETWORK_AUTHENTICATION_REQUIRED]:\n    \"Network Authentication Required\",\n} as const;\n","import type { NextFunction, Request, Response } from \"express\";\nimport { DefaultStatusMessages, HttpStatusCodes } from \"./statusCodes\";\n\n/**\n * Convert a numeric HTTP status code to its constant key name from `HttpStatusCodes`.\n * Example: `500 -> 'INTERNAL_SERVER_ERROR'`.\n */\nconst getStatusCodeKey = (statusCode: number): string => {\n  const match = Object.keys(HttpStatusCodes).find(\n    (k) => (HttpStatusCodes as any)[k] === statusCode\n  );\n  return match ?? \"INTERNAL_SERVER_ERROR\";\n};\n\n/**\n * Base application error class that extends the native Error class.\n * Used to create standardized application errors with HTTP status codes.\n * \n * @example\n * const error = new AppError('Something went wrong', 500);\n * \n * @class\n * @extends {Error}\n */\nexport class AppError extends Error {\n  public code: string;\n  /**\n   * Creates an AppError instance.\n   * @param {string} message - The error message\n   * @param {number} statusCode - The HTTP status code (e.g., 400, 500)\n   * @param {boolean} [isOparational=true] - Whether this is an operational error that can be handled gracefully\n   * @param {string} [code] - A short machine-friendly error code (e.g. 'NOT_FOUND')\n   */\n  constructor(\n    public message: string,\n    public statusCode: number,\n    public isOparational: boolean = true,\n    code?: string\n  ) {\n    super(message);\n    this.code = code ?? getStatusCodeKey(statusCode);\n    Object.setPrototypeOf(this, AppError.prototype);\n    // Error.captureStackTrace(this, this.constructor);\n  }\n}\n\n/**\n * Server error class for 5xx HTTP status codes.\n * Represents errors that occur on the server side.\n * \n * @example\n * throw new ServerError('Database connection failed');\n * \n * @class\n * @extends {AppError}\n */\nexport class ServerError extends AppError {\n  /**\n   * Creates a ServerError instance.\n   * @param {string} message - The error message describing the server error\n   * @param {number} [statusCode=500] - The HTTP status code (defaults to 500 Internal Server Error)\n   */\n  constructor(\n    message: string,\n    statusCode: number = HttpStatusCodes.INTERNAL_SERVER_ERROR\n  ) {\n    super(message, statusCode, true);\n  }\n}\n\n/**\n * Bad request error class for 400 HTTP status code.\n * Represents client request errors with invalid parameters or format.\n * \n * @example\n * throw new BadRequestError('Invalid email format');\n * \n * @class\n * @extends {AppError}\n */\nexport class BadRequestError extends AppError {\n    /**\n     * Creates a BadRequestError instance.\n     * @param {string} [message='Bad Request'] - The error message (defaults to standard 400 message)\n     */\n    constructor(message: string = DefaultStatusMessages[HttpStatusCodes.BAD_REQUEST]) {\n        super(message, HttpStatusCodes.BAD_REQUEST, true);\n    }\n}\n\n/**\n * Not found error class for 404 HTTP status code.\n * Represents when a requested resource cannot be found.\n * \n * @example\n * throw new NotFoundError('User not found');\n * \n * @class\n * @extends {AppError}\n */\nexport class NotFoundError extends AppError {\n    /**\n     * Creates a NotFoundError instance.\n     * @param {string} [message='Not Found'] - The error message (defaults to standard 404 message)\n     */\n    constructor(message: string = DefaultStatusMessages[HttpStatusCodes.NOT_FOUND]) {\n        super(message, HttpStatusCodes.NOT_FOUND, true);\n    }\n}\n\n/**\n * Unauthorized error class for 401 HTTP status code.\n * Represents authentication failures or missing credentials.\n * \n * @example\n * throw new UnauthorizedError('Invalid credentials');\n * \n * @class\n * @extends {AppError}\n */\nexport class UnauthorizedError extends AppError {\n    /**\n     * Creates an UnauthorizedError instance.\n     * @param {string} [message='Unauthorized'] - The error message (defaults to standard 401 message)\n     */\n    constructor(message: string = DefaultStatusMessages[HttpStatusCodes.UNAUTHORIZED]) {\n        super(message, HttpStatusCodes.UNAUTHORIZED, true);\n    }\n}\n\n/**\n * Forbidden error class for 403 HTTP status code.\n * Represents when a user is authenticated but lacks permission to access a resource.\n * \n * @example\n * throw new ForbiddenError('You do not have permission to access this resource');\n * \n * @class\n * @extends {AppError}\n */\nexport class ForbiddenError extends AppError {\n    /**\n     * Creates a ForbiddenError instance.\n     * @param {string} [message='Forbidden'] - The error message (defaults to standard 403 message)\n     */\n    constructor(message: string = DefaultStatusMessages[HttpStatusCodes.FORBIDDEN]) {\n        super(message, HttpStatusCodes.FORBIDDEN, true);\n    }\n}\n\n/**\n * Conflict error class for 409 HTTP status code.\n * Represents resource conflicts such as duplicate entries or version conflicts.\n * \n * @example\n * throw new ConflictError('Email already exists');\n * \n * @class\n * @extends {AppError}\n */\nexport class ConflictError extends AppError {\n    /**\n     * Creates a ConflictError instance.\n     * @param {string} [message='Conflict'] - The error message (defaults to standard 409 message)\n     */\n    constructor(message: string = DefaultStatusMessages[HttpStatusCodes.CONFLICT]) {\n        super(message, HttpStatusCodes.CONFLICT, true);\n    }\n}\n\n/**\n * Unprocessable entity error class for 422 HTTP status code.\n * Represents validation errors where the request format is correct but semantically incorrect.\n * \n * @example\n * throw new UnprocessableEntityError('Invalid data provided');\n * \n * @class\n * @extends {AppError}\n */\nexport class UnprocessableEntityError extends AppError {\n    /**\n     * Creates an UnprocessableEntityError instance.\n     * @param {string} [message='Unprocessable Entity'] - The error message (defaults to standard 422 message)\n     */\n    constructor(message: string = DefaultStatusMessages[HttpStatusCodes.UNPROCESSABLE_ENTITY]) {\n        super(message, HttpStatusCodes.UNPROCESSABLE_ENTITY, true);\n    }\n}\n\n/**\n * Method not allowed error class for 405 HTTP status code.\n * Represents when a request method (GET, POST, etc.) is not allowed for a resource.\n * \n * @example\n * throw new MethodNotAllowedError('POST method not allowed on this endpoint');\n * \n * @class\n * @extends {AppError}\n */\nexport class MethodNotAllowedError extends AppError {\n  /**\n   * Creates a MethodNotAllowedError instance.\n   * @param {string} [message='Method Not Allowed'] - The error message (defaults to standard 405 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.METHOD_NOT_ALLOWED]) {\n    super(message, HttpStatusCodes.METHOD_NOT_ALLOWED, true);\n  }\n}\n\n/**\n * Not acceptable error class for 406 HTTP status code.\n * Represents when the server cannot produce a response matching acceptable media types.\n * \n * @example\n * throw new NotAcceptableError('Requested format not supported');\n * \n * @class\n * @extends {AppError}\n */\nexport class NotAcceptableError extends AppError {\n  /**\n   * Creates a NotAcceptableError instance.\n   * @param {string} [message='Not Acceptable'] - The error message (defaults to standard 406 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.NOT_ACCEPTABLE]) {\n    super(message, HttpStatusCodes.NOT_ACCEPTABLE, true);\n  }\n}\n\n/**\n * Request timeout error class for 408 HTTP status code.\n * Represents when the server times out waiting for the client request.\n * \n * @example\n * throw new RequestTimeoutError('Request took too long to complete');\n * \n * @class\n * @extends {AppError}\n */\nexport class RequestTimeoutError extends AppError {\n  /**\n   * Creates a RequestTimeoutError instance.\n   * @param {string} [message='Request Timeout'] - The error message (defaults to standard 408 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.REQUEST_TIMEOUT]) {\n    super(message, HttpStatusCodes.REQUEST_TIMEOUT, true);\n  }\n}\n\n/**\n * Payload too large error class for 413 HTTP status code.\n * Represents when the request body exceeds the server's maximum allowed size.\n * \n * @example\n * throw new PayloadTooLargeError('File size exceeds 10MB limit');\n * \n * @class\n * @extends {AppError}\n */\nexport class PayloadTooLargeError extends AppError {\n  /**\n   * Creates a PayloadTooLargeError instance.\n   * @param {string} [message='Payload Too Large'] - The error message (defaults to standard 413 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.PAYLOAD_TOO_LARGE]) {\n    super(message, HttpStatusCodes.PAYLOAD_TOO_LARGE, true);\n  }\n}\n\n/**\n * Unsupported media type error class for 415 HTTP status code.\n * Represents when the request body media type is not supported.\n * \n * @example\n * throw new UnsupportedMediaTypeError('application/xml not supported');\n * \n * @class\n * @extends {AppError}\n */\nexport class UnsupportedMediaTypeError extends AppError {\n  /**\n   * Creates an UnsupportedMediaTypeError instance.\n   * @param {string} [message='Unsupported Media Type'] - The error message (defaults to standard 415 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE]) {\n    super(message, HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE, true);\n  }\n}\n\n/**\n * Too many requests error class for 429 HTTP status code.\n * Represents rate limiting when too many requests are received in a short time.\n * \n * @example\n * throw new TooManyRequestsError('Rate limit exceeded. Please try again later.');\n * \n * @class\n * @extends {AppError}\n */\nexport class TooManyRequestsError extends AppError {\n  /**\n   * Creates a TooManyRequestsError instance.\n   * @param {string} [message='Too Many Requests'] - The error message (defaults to standard 429 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.TOO_MANY_REQUESTS]) {\n    super(message, HttpStatusCodes.TOO_MANY_REQUESTS, true);\n  }\n}\n\n/**\n * Payment required error class for 402 HTTP status code.\n * Represents when payment is required to access the resource.\n * \n * @example\n * throw new PaymentRequiredError('Premium subscription required');\n * \n * @class\n * @extends {AppError}\n */\nexport class PaymentRequiredError extends AppError {\n  /**\n   * Creates a PaymentRequiredError instance.\n   * @param {string} [message='Payment Required'] - The error message (defaults to standard 402 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.PAYMENT_REQUIRED]) {\n    super(message, HttpStatusCodes.PAYMENT_REQUIRED, true);\n  }\n}\n\n/**\n * Gone error class for 410 HTTP status code.\n * Represents when the requested resource is permanently gone and won't be available again.\n * \n * @example\n * throw new GoneError('This resource has been permanently deleted');\n * \n * @class\n * @extends {AppError}\n */\nexport class GoneError extends AppError {\n  /**\n   * Creates a GoneError instance.\n   * @param {string} [message='Gone'] - The error message (defaults to standard 410 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.GONE]) {\n    super(message, HttpStatusCodes.GONE, true);\n  }\n}\n\n/**\n * Precondition failed error class for 412 HTTP status code.\n * Represents when server rejects request due to precondition headers (e.g., If-Match).\n * \n * @example\n * throw new PreconditionFailedError('ETag does not match current version');\n * \n * @class\n * @extends {AppError}\n */\nexport class PreconditionFailedError extends AppError {\n  /**\n   * Creates a PreconditionFailedError instance.\n   * @param {string} [message='Precondition Failed'] - The error message (defaults to standard 412 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.PRECONDITION_FAILED]) {\n    super(message, HttpStatusCodes.PRECONDITION_FAILED, true);\n  }\n}\n\n/**\n * Not implemented error class for 501 HTTP status code.\n * Represents when the server does not support the functionality required to fulfill the request.\n * \n * @example\n * throw new NotImplementedError('This feature is not yet implemented');\n * \n * @class\n * @extends {AppError}\n */\nexport class NotImplementedError extends AppError {\n  /**\n   * Creates a NotImplementedError instance.\n   * @param {string} [message='Not Implemented'] - The error message (defaults to standard 501 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.NOT_IMPLEMENTED]) {\n    super(message, HttpStatusCodes.NOT_IMPLEMENTED, true);\n  }\n}\n\n/**\n * Bad gateway error class for 502 HTTP status code.\n * Represents when the server received an invalid response from an upstream server.\n * \n * @example\n * throw new BadGatewayError('Upstream server returned invalid response');\n * \n * @class\n * @extends {AppError}\n */\nexport class BadGatewayError extends AppError {\n  /**\n   * Creates a BadGatewayError instance.\n   * @param {string} [message='Bad Gateway'] - The error message (defaults to standard 502 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.BAD_GATEWAY]) {\n    super(message, HttpStatusCodes.BAD_GATEWAY, true);\n  }\n}\n\n/**\n * Service unavailable error class for 503 HTTP status code.\n * Represents when the server is temporarily unable to handle requests (maintenance, overload, etc.).\n * \n * @example\n * throw new ServiceUnavailableError('Server is under maintenance');\n * \n * @class\n * @extends {AppError}\n */\nexport class ServiceUnavailableError extends AppError {\n  /**\n   * Creates a ServiceUnavailableError instance.\n   * @param {string} [message='Service Unavailable'] - The error message (defaults to standard 503 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.SERVICE_UNAVAILABLE]) {\n    super(message, HttpStatusCodes.SERVICE_UNAVAILABLE, true);\n  }\n}\n\n/**\n * Gateway timeout error class for 504 HTTP status code.\n * Represents when an upstream server fails to respond within the timeout period.\n * \n * @example\n * throw new GatewayTimeoutError('Upstream server did not respond in time');\n * \n * @class\n * @extends {AppError}\n */\nexport class GatewayTimeoutError extends AppError {\n  /**\n   * Creates a GatewayTimeoutError instance.\n   * @param {string} [message='Gateway Timeout'] - The error message (defaults to standard 504 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.GATEWAY_TIMEOUT]) {\n    super(message, HttpStatusCodes.GATEWAY_TIMEOUT, true);\n  }\n}\n\n/**\n * Insufficient storage error class for 507 HTTP status code.\n * Represents when the server is unable to store the representation needed to complete the request.\n * \n * @example\n * throw new InsufficientStorageError('Disk quota exceeded');\n * \n * @class\n * @extends {AppError}\n */\nexport class InsufficientStorageError extends AppError {\n  /**\n   * Creates an InsufficientStorageError instance.\n   * @param {string} [message='Insufficient Storage'] - The error message (defaults to standard 507 message)\n   */\n  constructor(message: string = DefaultStatusMessages[HttpStatusCodes.INSUFFICIENT_STORAGE]) {\n    super(message, HttpStatusCodes.INSUFFICIENT_STORAGE, true);\n  }\n}\n\n/**\n * Processes an error and returns a standardized error response object.\n * If the error is an operational AppError, returns its details.\n * Otherwise, returns a generic 500 Internal Server Error response.\n * \n * @param {Error | AppError} err - The error to handle\n * @returns {{status: string, statusCode: number, message: string}} Standardized error response object\n * \n * @example\n * const response = handleError(new NotFoundError('User not found'));\n * // Returns: { status: 'error', statusCode: 404, message: 'User not found' }\n */\nexport const handleError = (err: Error | AppError) => {\n  if (err instanceof AppError && err.isOparational) {\n    return {\n      status: \"error\",\n      statusCode: err.statusCode,\n      message: err.message,\n      code: err.code,\n    };\n  }\n\n  return {\n    status: \"error\",\n    statusCode: HttpStatusCodes.INTERNAL_SERVER_ERROR,\n    message: DefaultStatusMessages[HttpStatusCodes.INTERNAL_SERVER_ERROR],\n    code: getStatusCodeKey(HttpStatusCodes.INTERNAL_SERVER_ERROR),\n  };\n};\n\n/**\n * Express error handling middleware for catching and responding to errors.\n * This middleware should be placed at the end of all route handlers and middleware.\n * It catches any errors thrown in routes and sends a proper error response.\n * \n * @param {Error | AppError} err - The error object caught by Express\n * @param {Request} _req - Express request object (unused)\n * @param {Response} res - Express response object\n * @param {NextFunction} _next - Express next function (unused)\n * \n * @example\n * app.use(globalErrorHandler);\n */\nexport const globalErrorHandler = (\n  err: Error | AppError,\n  _req: Request,\n  res: Response,\n  _next: NextFunction\n) => {\n  const errorResponse = handleError(err);\n  res.status(errorResponse.statusCode).json({\n    status: errorResponse.status,\n    statusCode: errorResponse.statusCode,\n    message: errorResponse.message,\n    code: errorResponse.code,\n    // ...(process.env.NODE_ENV === 'development' && { stack: err.stack })\n  });\n};\n"],"mappings":"AAAA,OAAOA,MAAW,2BAClB,OAAOC,MAAY,qBCkBZ,IAAMC,EAAkB,CAG7B,SAAU,IAEV,oBAAqB,IAErB,WAAY,IAEZ,YAAa,IAIb,GAAI,IAEJ,QAAS,IAET,SAAU,IAEV,8BAA+B,IAE/B,WAAY,IAEZ,cAAe,IAEf,gBAAiB,IAEjB,aAAc,IAEd,iBAAkB,IAElB,QAAS,IAIT,iBAAkB,IAElB,kBAAmB,IAEnB,MAAO,IAEP,UAAW,IAEX,aAAc,IAEd,UAAW,IAEX,mBAAoB,IAEpB,mBAAoB,IAIpB,YAAa,IAEb,aAAc,IAEd,iBAAkB,IAElB,UAAW,IAEX,UAAW,IAEX,mBAAoB,IAEpB,eAAgB,IAEhB,8BAA+B,IAE/B,gBAAiB,IAEjB,SAAU,IAEV,KAAM,IAEN,gBAAiB,IAEjB,oBAAqB,IAErB,kBAAmB,IAEnB,aAAc,IAEd,uBAAwB,IAExB,sBAAuB,IAEvB,mBAAoB,IAEpB,YAAa,IAEb,oBAAqB,IAErB,qBAAsB,IAEtB,OAAQ,IAER,kBAAmB,IAEnB,UAAW,IAEX,iBAAkB,IAElB,sBAAuB,IAEvB,kBAAmB,IAEnB,gCAAiC,IAEjC,8BAA+B,IAI/B,sBAAuB,IAEvB,gBAAiB,IAEjB,YAAa,IAEb,oBAAqB,IAErB,gBAAiB,IAEjB,2BAA4B,IAE5B,wBAAyB,IAEzB,qBAAsB,IAEtB,cAAe,IAEf,aAAc,IAEd,gCAAiC,GACnC,EAgBaC,EAAwB,CAEnC,CAACD,EAAgB,QAAQ,EAAG,WAC5B,CAACA,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AAU,CACrC,MAAOG,EAAG,OACV,SAAU,EACZ,CAAC,EACML,EAAYK,EAAIH,CAAqB,CAC9C,CAQA,SAASQ,GAAmB,CAC1B,IAAMC,EAAgBC,EAAO,UAAU,YAAY,MACnDA,EAAO,UAAU,YAAY,MAAQ,SACnCC,EACAR,EACA,CACA,OAAAA,EAAKD,EAAKC,CAAE,EACLM,EAAc,KAAK,KAAME,EAAMR,CAAE,CAC1C,CACF,CAOA,OAAO,eAAeS,EAAM,UAAW,SAAU,CAC/C,WAAY,GACZ,KAAM,CACJ,OAAQ,KAAa,QACvB,EACA,IAAIT,EAAc,CAChBA,EAAKD,EAAKC,CAAE,EACX,KAAa,SAAWA,CAC3B,CACF,CAAC,EAMDK,EAAiB","names":["Layer","Router","HttpStatusCodes","DefaultStatusMessages","getStatusCodeKey","statusCode","HttpStatusCodes","k","AppError","_AppError","message","isOparational","code","ServerError","BadRequestError","DefaultStatusMessages","NotFoundError","UnauthorizedError","ForbiddenError","ConflictError","UnprocessableEntityError","MethodNotAllowedError","NotAcceptableError","RequestTimeoutError","PayloadTooLargeError","UnsupportedMediaTypeError","TooManyRequestsError","PaymentRequiredError","GoneError","PreconditionFailedError","NotImplementedError","BadGatewayError","ServiceUnavailableError","GatewayTimeoutError","InsufficientStorageError","handleError","err","globalErrorHandler","_req","res","_next","errorResponse","last","arr","noop","copyFnProps","oldFn","newFn","key","wrap","fn","args","ret","next","err","patchRouterParam","originalParam","Router","name","Layer"]}