UNPKG

@sigiljs/sigil

Version:

TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating

768 lines (767 loc) 17.7 kB
import s from "./exception.mjs"; function o(t, e) { return e.length > 0 ? e : [t]; } class a extends s { static name = "BadRequest"; /** * The server could not understand the request due to malformed syntax. * * @param message optional error message */ constructor(...e) { super({ code: 400, name: "BadRequest", message: o( "The server could not understand the request due to malformed syntax.", e ) }); } } class n extends s { static name = "Unauthorized"; /** * The request requires user authentication. * * @param message optional error message */ constructor(...e) { super({ code: 401, name: "Unauthorized", message: o( "The request requires user authentication.", e ) }); } } class c extends s { static name = "PaymentRequired"; /** * Payment is required to process the request. * * @param message optional error message */ constructor(...e) { super({ code: 402, name: "PaymentRequired", message: o( "Payment is required to process the request.", e ) }); } } class i extends s { static name = "Forbidden"; /** * The server understood the request, but refuses to authorize it. * * @param message optional error message */ constructor(...e) { super({ code: 403, name: "Forbidden", message: o( "The server understood the request, but refuses to authorize it.", e ) }); } } class d extends s { static name = "NotFound"; /** * The requested resource could not be found on the server. * * @param message optional error message */ constructor(...e) { super({ code: 404, name: "NotFound", message: o( "The requested resource could not be found on the server.", e ) }); } } class u extends s { static name = "MethodNotAllowed"; /** * The request method is not allowed on the requested resource. * * @param message optional error message */ constructor(...e) { super({ code: 405, name: "MethodNotAllowed", message: o( "The request method is not allowed on the requested resource.", e ) }); } } class l extends s { static name = "NotAcceptable"; /** * The requested resource is capable of generating only response not acceptable according to the Accept headers. * * @param message optional error message */ constructor(...e) { super({ code: 406, name: "NotAcceptable", message: o( "The requested resource is capable of generating only response not acceptable according to the Accept headers.", e ) }); } } class m extends s { static name = "ProxyAuthenticationRequired"; /** * Proxy authentication is required to process the request. * * @param message optional error message */ constructor(...e) { super({ code: 407, name: "ProxyAuthenticationRequired", message: o( "Proxy authentication is required to process the request.", e ) }); } } class p extends s { static name = "RequestTimeout"; /** * The server timed out waiting for the client request. * * @param message optional error message */ constructor(...e) { super({ code: 408, name: "RequestTimeout", message: o( "The server timed out waiting for the client request.", e ) }); } } class h extends s { static name = "Conflict"; /** * The request could not be completed due to a conflict with the current state of the resource. * * @param message optional error message */ constructor(...e) { super({ code: 409, name: "Conflict", message: o( "The request could not be completed due to a conflict with the current state of the resource.", e ) }); } } class g extends s { static name = "Gone"; /** * The requested resource is no longer available and has been permanently removed. * * @param message optional error message */ constructor(...e) { super({ code: 410, name: "Gone", message: o( "The requested resource is no longer available and has been permanently removed.", e ) }); } } class q extends s { static name = "LengthRequired"; /** * The request did not specify the length of its response, which is required by the requested resource. * * @param message optional error message */ constructor(...e) { super({ code: 411, name: "LengthRequired", message: o( "The request did not specify the length of its response, which is required by the requested resource.", e ) }); } } class T extends s { static name = "PreconditionFailed"; /** * The precondition given in one or more request-header fields evaluated to false when it was tested on the server. * * @param message optional error message */ constructor(...e) { super({ code: 412, name: "PreconditionFailed", message: o( "The precondition given in one or more request-header fields evaluated to false when it was tested on the server.", e ) }); } } class x extends s { static name = "PayloadTooLarge"; /** * The request entity is larger than the server is willing or able to process. * * @param message optional error message */ constructor(...e) { super({ code: 413, name: "PayloadTooLarge", message: o( "The request entity is larger than the server is willing or able to process.", e ) }); } } class f extends s { static name = "URITooLong"; /** * The URI provided was too long for the server to process. * * @param message optional error message */ constructor(...e) { super({ code: 414, name: "URITooLong", message: o( "The URI provided was too long for the server to process.", e ) }); } } class v extends s { static name = "UnsupportedMediaType"; /** * The request entity has a media type that the server or resource does not support. * * @param message optional error message */ constructor(...e) { super({ code: 415, name: "UnsupportedMediaType", message: o( "The request entity has a media type that the server or resource does not support.", e ) }); } } class y extends s { static name = "RangeNotSatisfiable"; /** * The client has asked for a portion of the file, but the server cannot supply that portion. * * @param message optional error message */ constructor(...e) { super({ code: 416, name: "RangeNotSatisfiable", message: o( "The client has asked for a portion of the file, but the server cannot supply that portion.", e ) }); } } class R extends s { static name = "ExpectationFailed"; /** * The server cannot meet the requirements of the Expect request-header field. * * @param message optional error message */ constructor(...e) { super({ code: 417, name: "ExpectationFailed", message: o( "The server cannot meet the requirements of the Expect request-header field.", e ) }); } } class b extends s { static name = "ImATeapot"; /** * The server refuses the attempt to brew coffee with a teapot. * * @param message optional error message */ constructor(...e) { super({ code: 418, name: "ImATeapot", message: o( "The server refuses the attempt to brew coffee with a teapot.", e ) }); } } class w extends s { static name = "MisdirectedRequest"; /** * The request was directed at a server that is not able to produce a response. * * @param message optional error message */ constructor(...e) { super({ code: 421, name: "MisdirectedRequest", message: o( "The request was directed at a server that is not able to produce a response.", e ) }); } } class N extends s { static name = "UnprocessableEntity"; /** * The request was well-formed but unable to be followed due to semantic errors. * * @param message optional error message */ constructor(...e) { super({ code: 422, name: "UnprocessableEntity", message: o( "The request was well-formed but unable to be followed due to semantic errors.", e ) }); } } class F extends s { static name = "Locked"; /** * The resource that is being accessed is locked. * * @param message optional error message */ constructor(...e) { super({ code: 423, name: "Locked", message: o( "The resource that is being accessed is locked.", e ) }); } } class U extends s { static name = "FailedDependency"; /** * The request failed due to the failure of a previous request. * * @param message optional error message */ constructor(...e) { super({ code: 424, name: "FailedDependency", message: o( "The request failed due to the failure of a previous request.", e ) }); } } class L extends s { static name = "TooEarly"; /** * The server is unwilling to risk processing a request that might be replayed. * * @param message optional error message */ constructor(...e) { super({ code: 425, name: "TooEarly", message: o( "The server is unwilling to risk processing a request that might be replayed.", e ) }); } } class P extends s { static name = "UpgradeRequired"; /** * The server refuses to process the request without an upgrade to a different protocol. * * @param message optional error message */ constructor(...e) { super({ code: 426, name: "UpgradeRequired", message: o( "The server refuses to process the request without an upgrade to a different protocol.", e ) }); } } class A extends s { static name = "PreconditionRequired"; /** * The origin server requires the request to be conditional. * * @param message optional error message */ constructor(...e) { super({ code: 428, name: "PreconditionRequired", message: o( "The origin server requires the request to be conditional.", e ) }); } } class E extends s { static name = "TooManyRequests"; /** * The user has sent too many requests in a given amount of time. * * @param message optional error message */ constructor(...e) { super({ code: 429, name: "TooManyRequests", message: o( "The user has sent too many requests in a given amount of time.", e ) }); } } class I extends s { static name = "RequestHeaderFieldsTooLarge"; /** * The server is unwilling to process the request because its header fields are too large. * * @param message optional error message */ constructor(...e) { super({ code: 431, name: "RequestHeaderFieldsTooLarge", message: o( "The server is unwilling to process the request because its header fields are too large.", e ) }); } } class S extends s { static name = "UnavailableForLegalReasons"; /** * The resource requested is unavailable due to legal reasons. * * @param message optional error message */ constructor(...e) { super({ code: 451, name: "UnavailableForLegalReasons", message: o( "The resource requested is unavailable due to legal reasons.", e ) }); } } class M extends s { static name = "InternalServerError"; /** * The server encountered an unexpected condition that prevented it from fulfilling the request. * * @param message optional error message */ constructor(...e) { super({ code: 500, name: "InternalServerError", message: o( "The server encountered an unexpected condition that prevented it from fulfilling the request.", e ) }); } } class k extends s { static name = "NotImplemented"; /** * The server does not support the functionality required to fulfill the request. * * @param message optional error message */ constructor(...e) { super({ code: 501, name: "NotImplemented", message: o( "The server does not support the functionality required to fulfill the request.", e ) }); } } class G extends s { static name = "BadGateway"; /** * The server, while acting as a gateway or proxy, received an invalid response from the upstream server. * * @param message optional error message */ constructor(...e) { super({ code: 502, name: "BadGateway", message: o( "The server, while acting as a gateway or proxy, received an invalid response from the upstream server.", e ) }); } } class H extends s { static name = "ServiceUnavailable"; /** * The server is currently unable to handle the request due to a temporary overload or maintenance. * * @param message optional error message */ constructor(...e) { super({ code: 503, name: "ServiceUnavailable", message: o( "The server is currently unable to handle the request due to a temporary overload or maintenance.", e ) }); } } class B extends s { static name = "GatewayTimeout"; /** * The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server. * * @param message optional error message */ constructor(...e) { super({ code: 504, name: "GatewayTimeout", message: o( "The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server.", e ) }); } } class D extends s { static name = "HTTPVersionNotSupported"; /** * The server does not support the HTTP protocol version used in the request. * * @param message optional error message */ constructor(...e) { super({ code: 505, name: "HTTPVersionNotSupported", message: o( "The server does not support the HTTP protocol version used in the request.", e ) }); } } class V extends s { static name = "VariantAlsoNegotiates"; /** * The server has an internal configuration error and is unable to complete the request. * * @param message optional error message */ constructor(...e) { super({ code: 506, name: "VariantAlsoNegotiates", message: o( "The server has an internal configuration error and is unable to complete the request.", e ) }); } } class z extends s { static name = "InsufficientStorage"; /** * The server is unable to store the representation needed to complete the request. * * @param message optional error message */ constructor(...e) { super({ code: 507, name: "InsufficientStorage", message: o( "The server is unable to store the representation needed to complete the request.", e ) }); } } class C extends s { static name = "LoopDetected"; /** * The server detected an infinite loop while processing the request. * * @param message optional error message */ constructor(...e) { super({ code: 508, name: "LoopDetected", message: o( "The server detected an infinite loop while processing the request.", e ) }); } } class j extends s { static name = "NotExtended"; /** * Further extensions to the request are required for the server to fulfill it. * * @param message optional error message */ constructor(...e) { super({ code: 510, name: "NotExtended", message: o( "Further extensions to the request are required for the server to fulfill it.", e ) }); } } class J extends s { static name = "NetworkAuthenticationRequired"; /** * The client needs to authenticate to gain network access. * * @param message optional error message */ constructor(...e) { super({ code: 511, name: "NetworkAuthenticationRequired", message: o( "The client needs to authenticate to gain network access.", e ) }); } } export { G as BadGateway, a as BadRequest, h as Conflict, s as Exception, R as ExpectationFailed, U as FailedDependency, i as Forbidden, B as GatewayTimeout, g as Gone, D as HTTPVersionNotSupported, b as ImATeapot, z as InsufficientStorage, M as InternalServerError, q as LengthRequired, F as Locked, C as LoopDetected, u as MethodNotAllowed, w as MisdirectedRequest, J as NetworkAuthenticationRequired, l as NotAcceptable, j as NotExtended, d as NotFound, k as NotImplemented, x as PayloadTooLarge, c as PaymentRequired, T as PreconditionFailed, A as PreconditionRequired, m as ProxyAuthenticationRequired, y as RangeNotSatisfiable, I as RequestHeaderFieldsTooLarge, p as RequestTimeout, H as ServiceUnavailable, L as TooEarly, E as TooManyRequests, f as URITooLong, n as Unauthorized, S as UnavailableForLegalReasons, N as UnprocessableEntity, v as UnsupportedMediaType, P as UpgradeRequired, V as VariantAlsoNegotiates };