tsunamy
Version:
A new typesript framework
119 lines (118 loc) • 6.52 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var HttpStatus = /** @class */ (function () {
function HttpStatus(code, reasonPhrase) {
this.code = code;
this.reasonPhrase = reasonPhrase;
this.code = code;
this.reasonPhrase = reasonPhrase;
}
/**
* Get first HttpStatus matching a code
*
* @param code searched
* @return HttpStatus matching code searched
*/
HttpStatus.getValueOf = function (code) {
return Object.keys(HttpStatus)
.filter(function (key) {
// Keep only static field of object type (HttpStatus)
return (typeof HttpStatus[key] === 'object');
})
.map(function (key) {
return HttpStatus[key];
})
.filter(function (status) {
if (status.getCode() === code) {
return true;
}
})[0];
};
/**
* Return the integer value of this status code
*/
HttpStatus.prototype.getCode = function () {
return this.code;
};
/**
* Return the reason phrase of this status code
*/
HttpStatus.prototype.getReasonPhrase = function () {
return this.reasonPhrase;
};
// 1xx Informational
HttpStatus.CONTINUE = new HttpStatus(100, 'Continue');
HttpStatus.SWITCHING_PROTOCOLS = new HttpStatus(101, 'Switching Protocols');
HttpStatus.PROCESSING = new HttpStatus(102, 'Processing');
HttpStatus.CHECKPOINT = new HttpStatus(103, 'Checkpoint');
// 2xx Success
HttpStatus.OK = new HttpStatus(200, 'OK');
HttpStatus.CREATED = new HttpStatus(201, 'Created');
HttpStatus.ACCEPTED = new HttpStatus(202, 'Accepted');
HttpStatus.NON_AUTHORITATIVE_INFORMATION = new HttpStatus(203, 'Non-Authoritative Information');
HttpStatus.NO_CONTENT = new HttpStatus(204, 'No Content');
HttpStatus.RESET_CONTENT = new HttpStatus(205, 'Reset Content');
HttpStatus.PARTIAL_CONTENT = new HttpStatus(206, 'Partial Content');
HttpStatus.MULTI_STATUS = new HttpStatus(207, 'Multi-Status');
HttpStatus.ALREADY_REPORTED = new HttpStatus(208, 'Already Reported');
HttpStatus.IM_USED = new HttpStatus(226, 'IM Used');
// 3xx Redirection
HttpStatus.MULTIPLE_CHOICES = new HttpStatus(300, 'Multiple Choices');
HttpStatus.MOVED_PERMANENTLY = new HttpStatus(301, 'Moved Permanently');
HttpStatus.FOUND = new HttpStatus(302, 'Found');
HttpStatus.MOVED_TEMPORARILY = new HttpStatus(302, 'Moved Temporarily');
HttpStatus.SEE_OTHER = new HttpStatus(303, 'See Other');
HttpStatus.NOT_MODIFIED = new HttpStatus(304, 'Not Modified');
HttpStatus.USE_PROXY = new HttpStatus(305, 'Use Proxy');
HttpStatus.TEMPORARY_REDIRECT = new HttpStatus(307, 'Temporary Redirect');
HttpStatus.PERMANENT_REDIRECT = new HttpStatus(308, 'Permanent Redirect');
// 4xx Client Error
HttpStatus.BAD_REQUEST = new HttpStatus(400, 'Bad Request');
HttpStatus.UNAUTHORIZED = new HttpStatus(401, 'Unauthorized');
HttpStatus.PAYMENT_REQUIRED = new HttpStatus(402, 'Payment Required');
HttpStatus.FORBIDDEN = new HttpStatus(403, 'Forbidden');
HttpStatus.NOT_FOUND = new HttpStatus(404, 'Not Found');
HttpStatus.METHOD_NOT_ALLOWED = new HttpStatus(405, 'Method Not Allowed');
HttpStatus.NOT_ACCEPTABLE = new HttpStatus(406, 'Not Acceptable');
HttpStatus.PROXY_AUTHENTICATION_REQUIRED = new HttpStatus(407, 'Proxy Authentication Required');
HttpStatus.REQUEST_TIMEOUT = new HttpStatus(408, 'Request Timeout');
HttpStatus.CONFLICT = new HttpStatus(409, 'Conflict');
HttpStatus.GONE = new HttpStatus(410, 'Gone');
HttpStatus.LENGTH_REQUIRED = new HttpStatus(411, 'Length Required');
HttpStatus.PRECONDITION_FAILED = new HttpStatus(412, 'Precondition Failed');
HttpStatus.PAYLOAD_TOO_LARGE = new HttpStatus(413, 'Payload Too Large');
HttpStatus.REQUEST_ENTITY_TOO_LARGE = new HttpStatus(413, 'Request Entity Too Large');
HttpStatus.URI_TOO_LONG = new HttpStatus(414, 'URI Too Long');
HttpStatus.REQUEST_URI_TOO_LONG = new HttpStatus(414, 'Request-URI Too Long');
HttpStatus.UNSUPPORTED_MEDIA_TYPE = new HttpStatus(415, 'Unsupported Media Type');
HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE = new HttpStatus(416, 'Requested range not satisfiable');
HttpStatus.EXPECTATION_FAILED = new HttpStatus(417, 'Expectation Failed');
HttpStatus.I_AM_A_TEAPOT = new HttpStatus(418, 'I\'m a teapot');
HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE = new HttpStatus(419, 'Insufficient Space On Resource');
HttpStatus.METHOD_FAILURE = new HttpStatus(420, 'Method Failure');
HttpStatus.DESTINATION_LOCKED = new HttpStatus(421, 'Destination Locked');
HttpStatus.UNPROCESSABLE_ENTITY = new HttpStatus(422, 'Unprocessable Entity');
HttpStatus.LOCKED = new HttpStatus(423, 'Locked');
HttpStatus.FAILED_DEPENDENCY = new HttpStatus(424, 'Failed Dependency');
HttpStatus.TOO_EARLY = new HttpStatus(425, 'Too Early');
HttpStatus.UPGRADE_REQUIRED = new HttpStatus(426, 'Upgrade Required');
HttpStatus.PRECONDITION_REQUIRED = new HttpStatus(428, 'Precondition Required');
HttpStatus.TOO_MANY_REQUESTS = new HttpStatus(429, 'Too Many Requests');
HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE = new HttpStatus(431, 'Request Header Fields Too Large');
HttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS = new HttpStatus(451, 'Unavailable For Legal Reasons');
// 5xx Server Error
HttpStatus.INTERNAL_SERVER_ERROR = new HttpStatus(500, 'Internal Server Error');
HttpStatus.NOT_IMPLEMENTED = new HttpStatus(501, 'Not Implemented');
HttpStatus.BAD_GATEWAY = new HttpStatus(502, 'Bad Gateway');
HttpStatus.SERVICE_UNAVAILABLE = new HttpStatus(503, 'Service Unavailable');
HttpStatus.GATEWAY_TIMEOUT = new HttpStatus(504, 'Gateway Timeout');
HttpStatus.HTTP_VERSION_NOT_SUPPORTED = new HttpStatus(505, 'HTTP Version not supported');
HttpStatus.VARIANT_ALSO_NEGOTIATES = new HttpStatus(506, 'Variant Also Negotiates');
HttpStatus.INSUFFICIENT_STORAGE = new HttpStatus(507, 'Insufficient Storage');
HttpStatus.LOOP_DETECTED = new HttpStatus(508, 'Loop Detected');
HttpStatus.BANDWIDTH_LIMIT_EXCEEDED = new HttpStatus(509, 'Bandwidth Limit Exceeded');
HttpStatus.NOT_EXTENDED = new HttpStatus(510, 'Not Extended');
HttpStatus.NETWORK_AUTHENTICATION_REQUIRED = new HttpStatus(511, 'Network Authentication Required');
return HttpStatus;
}());
exports.HttpStatus = HttpStatus;