@thisisagile/easy
Version:
Straightforward library for building domain-driven microservice architectures
94 lines (92 loc) • 4.89 kB
JavaScript
import {
Enum
} from "./chunk-AVHYDITZ.mjs";
import {
isAn
} from "./chunk-D5IYAIMK.mjs";
// src/http/HttpStatus.ts
var HttpStatus = class _HttpStatus extends Enum {
static Continue = new _HttpStatus("Continue", 100);
static SwitchingProtocols = new _HttpStatus("Switching protocols", 101);
static Processing = new _HttpStatus("Processing", 102);
static EarlyHints = new _HttpStatus("Early hints", 103);
static Ok = new _HttpStatus("Ok", 200);
static Created = new _HttpStatus("Created", 201);
static Accepted = new _HttpStatus("Accepted", 202);
static NonAuthoritativeInformation = new _HttpStatus("Non-authoritative information", 203);
static NoContent = new _HttpStatus("No content", 204);
static ResetContent = new _HttpStatus("Reset content", 205);
static PartialContent = new _HttpStatus("Partial content", 206);
static MultiStatus = new _HttpStatus("Multi-status", 207);
static AlreadyReported = new _HttpStatus("Already reported", 208);
static ImUsed = new _HttpStatus("IM used", 226);
static MultipleChoices = new _HttpStatus("Multiple Choices", 300);
static MovedPermanently = new _HttpStatus("Moved Permanently", 301);
static Found = new _HttpStatus("Found", 302);
static SeeOther = new _HttpStatus("See other", 303);
static NotModified = new _HttpStatus("Not modified", 304);
static UseProxy = new _HttpStatus("Use proxy", 305);
static SwitchProxy = new _HttpStatus("Switch proxy", 306);
static TemporaryRedirect = new _HttpStatus("Temporary redirect", 307);
static PermanentRedirect = new _HttpStatus("Permanent redirect", 308);
static BadRequest = new _HttpStatus("Bad request", 400);
static NotAuthorized = new _HttpStatus("Not authorized", 401);
static PaymentRequired = new _HttpStatus("Payment required", 402);
static Forbidden = new _HttpStatus("Forbidden", 403);
static NotFound = new _HttpStatus("Not found", 404);
static MethodNotAllowed = new _HttpStatus("Method not allowed", 405);
static NotAcceptable = new _HttpStatus("Not acceptable", 406);
static ProxyAuthenticationRequired = new _HttpStatus("Proxy authentication required", 407);
static RequestTimeout = new _HttpStatus("Request timeout", 408);
static Conflict = new _HttpStatus("Conflict", 409);
static Gone = new _HttpStatus("Gone", 410);
static LengthRequired = new _HttpStatus("Length required", 411);
static PreconditionFailed = new _HttpStatus("Precondition failed", 412);
static PayloadTooLarge = new _HttpStatus("Payload too large", 413);
static UriTooLong = new _HttpStatus("URI too long", 414);
static UnsupportedMediaType = new _HttpStatus("Unsupported media type", 415);
static RangeNotSatisfiable = new _HttpStatus("Range not satisfiable", 416);
static ExpectationFailed = new _HttpStatus("Expectation failed", 417);
static ImATeapot = new _HttpStatus("I'm a teapot", 418);
static MisdirectedRequest = new _HttpStatus("Misdirected request", 421);
static UnprocessableEntity = new _HttpStatus("Unprocessable entity", 422);
static Locked = new _HttpStatus("Locked", 423);
static FailedDependency = new _HttpStatus("Failed dependency", 424);
static TooEarly = new _HttpStatus("Too early", 425);
static UpgradeRequired = new _HttpStatus("Upgrade required", 426);
static PreconditionRequired = new _HttpStatus("Precondition required", 428);
static TooManyRequests = new _HttpStatus("Too many requests", 429);
static RequestHeaderFieldsTooLarge = new _HttpStatus("Request header fields too large", 431);
static UnavailableForLegalReasons = new _HttpStatus("Unavailable for legal reasons", 451);
static InternalServerError = new _HttpStatus("Internal server error", 500);
static NotImplemented = new _HttpStatus("Not implemented", 501);
static BadGateway = new _HttpStatus("Bad gateway", 502);
static ServiceUnavailable = new _HttpStatus("Service unavailable", 503);
static GatewayTimeout = new _HttpStatus("Gateway timeout", 504);
static HTTPVersionNotSupported = new _HttpStatus("Http version not supported", 505);
static VariantAlsoNegotiates = new _HttpStatus("Variant also negotiates", 506);
static InsufficientStorage = new _HttpStatus("Insufficient storage", 507);
static LoopDetected = new _HttpStatus("Loop detected", 508);
static NotExtended = new _HttpStatus("Not extended", 510);
static NetworkAuthenticationRequired = new _HttpStatus("Network authentication required", 511);
get isError() {
return this.isClientError || this.isServerError;
}
get isClientError() {
return this.id >= 400 && this.id < 500;
}
get isServerError() {
return this.id >= 500 && this.id < 600;
}
get status() {
return this.id;
}
};
var isHttpStatus = (s) => isAn(s, "id", "status");
var toHttpStatus = (s) => isHttpStatus(s) ? s : HttpStatus.byId(s);
export {
HttpStatus,
isHttpStatus,
toHttpStatus
};
//# sourceMappingURL=chunk-RPZ2XDQQ.mjs.map