lib-utils-ts
Version:
<img src="https://img.shields.io/npm/v/lib-utils-ts"/> <img src="https://img.shields.io/snyk/vulnerabilities/npm/lib-utils-ts"/> <img src="https://img.shields.io/npm/l/lib-utils-ts"/> <img src="https://img.shields.io/github/languages/top/devGnode/lib-util
48 lines (43 loc) • 1.77 kB
text/typescript
import {Enum} from "../../Enum";
export class Code extends Enum{
//2xx
.args(200) static readonly HTTP_OK:Code;
.args(201) static readonly HTTP_CREATED:Code;
.args(202) static readonly HTTP_ACCEPTED:Code;
.args(204) static readonly HTTP_NO_CONTENT:Code;
.args(205) static readonly HTTP_RESET_CONTENT:Code;
// 3xx
.args(300) static readonly HTTP_MULTIPLE_CHOICES:Code;
.args(301) static readonly HTTP_MOVE_PERMANENTLY:Code;
.args(302) static readonly HTTP_FOUND:Code;
.args(304) static readonly HTTP_NOT_MODIFIED:Code;
.args(305) static readonly HTTP_USE_PROXY:Code;
.args(310) static readonly HTTP_TOO_MANY_REDIRECTS:Code;
// 4xx
.args(400) static readonly HTTP_BAD_REQUEST:Code;
.args(401) static readonly HTTP_UNAUTHORIZED:Code;
.args(403) static readonly HTTP_FORBIDEN:Code;
.args(404) static readonly HTTP_NOT_FOUND:Code;
.args(405) static readonly HTTP_NOT_ALLOWED:Code;
.args(406) static readonly HTTP_NOT_ACCEPTABLE:Code;
// 5xx
.args(500) static readonly HTTP_INTERNAL_SERVER_ERROR:Code;
.args(502) static readonly HTTP_BAD_GATEWAY:Code;
.args(503) static readonly HTTP_SERVICE_UNAVAILABLE:Code;
.args(520) static readonly HTTP_UNKNOWN_ERROR:Code;
private readonly code:number;
private constructor(code:number) {super();this.code = code;}
/***
* Return status code
* @return {number}
*/
public get():number{ return this.code; }
/**@override*/
public toString(): string {
return super
.toString()
.replace(/\_|HTTP/gi," ")
.trimStart();
}
}
Object.package(this);