fix(core): update
This commit is contained in:
parent
fbe1b93a48
commit
dbaefbb3cc
@ -2,12 +2,9 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smartstatus from '../ts/index';
|
||||
|
||||
tap.test('should create valid status classes', async () => {
|
||||
const myStatus301 = new smartstatus.status301();
|
||||
console.log(myStatus301.code);
|
||||
console.log(myStatus301.text);
|
||||
console.log(myStatus301.description);
|
||||
return expect(myStatus301).to.be.instanceOf(smartstatus.HttpStatus);
|
||||
tap.test('should get a status by codeString', async () => {
|
||||
const status = smartstatus.HttpStatus.getHttpStatusByString('404');
|
||||
console.log(status);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
0
ts/Status401.ts
Normal file
0
ts/Status401.ts
Normal file
@ -1,6 +1,6 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
|
||||
export class status100 extends HttpStatus {
|
||||
export class Status100 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 100,
|
||||
@ -17,8 +17,9 @@ export class status100 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('100', Status100);
|
||||
|
||||
export class status101 extends HttpStatus {
|
||||
export class Status101 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 101,
|
||||
@ -27,8 +28,9 @@ export class status101 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('101', Status101);
|
||||
|
||||
export class status102 extends HttpStatus {
|
||||
export class Status102 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 102,
|
||||
@ -41,3 +43,4 @@ export class status102 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('102', Status102);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
|
||||
export class status200 extends HttpStatus {
|
||||
export class Status200 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 200,
|
||||
@ -12,8 +12,10 @@ export class status200 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('200', Status200);
|
||||
|
||||
export class status201 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status201 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 201,
|
||||
@ -22,8 +24,10 @@ export class status201 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('201', Status201);
|
||||
|
||||
export class status202 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status202 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 202,
|
||||
@ -33,8 +37,10 @@ export class status202 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('202', Status202);
|
||||
|
||||
export class status203 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status203 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 203,
|
||||
@ -44,8 +50,10 @@ export class status203 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('203', Status203);
|
||||
|
||||
export class status204 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status204 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 204,
|
||||
@ -54,8 +62,10 @@ export class status204 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('204', Status204);
|
||||
|
||||
export class status205 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status205 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 205,
|
||||
@ -65,8 +75,10 @@ export class status205 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('205', Status205);
|
||||
|
||||
export class status206 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status206 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 206,
|
||||
@ -78,8 +90,10 @@ export class status206 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('206', Status206);
|
||||
|
||||
export class status207 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status207 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 207,
|
||||
@ -90,8 +104,10 @@ export class status207 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('207', Status207);
|
||||
|
||||
export class status208 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status208 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 208,
|
||||
@ -102,8 +118,10 @@ export class status208 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('208', Status208);
|
||||
|
||||
export class status226 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status226 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 226,
|
||||
@ -114,3 +132,4 @@ export class status226 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('226', Status226);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
|
||||
export class status300 extends HttpStatus {
|
||||
export class Status300 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 300,
|
||||
@ -12,8 +12,10 @@ export class status300 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('300', Status300);
|
||||
|
||||
export class status301 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status301 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 301,
|
||||
@ -22,8 +24,10 @@ export class status301 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('301', Status301);
|
||||
|
||||
export class status302 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status302 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 302,
|
||||
@ -37,8 +41,10 @@ export class status302 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('302', Status302);
|
||||
|
||||
export class status303 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status303 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 303,
|
||||
@ -50,8 +56,10 @@ export class status303 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('303', Status303);
|
||||
|
||||
export class status304 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status304 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 304,
|
||||
@ -63,8 +71,10 @@ export class status304 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('304', Status304);
|
||||
|
||||
export class status305 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status305 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 305,
|
||||
@ -76,8 +86,10 @@ export class status305 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('305', Status305);
|
||||
|
||||
export class status306 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status306 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 306,
|
||||
@ -86,8 +98,10 @@ export class status306 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('306', Status306);
|
||||
|
||||
export class status307 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status307 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 307,
|
||||
@ -100,8 +114,10 @@ export class status307 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('307', Status307);
|
||||
|
||||
export class status308 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status308 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 308,
|
||||
@ -112,3 +128,4 @@ export class status308 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('308', Status308);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
|
||||
export class status400 extends HttpStatus {
|
||||
export class Status400 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 400,
|
||||
@ -9,8 +9,10 @@ export class status400 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('400', Status400);
|
||||
|
||||
export class status401 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status401 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 401,
|
||||
@ -20,8 +22,10 @@ export class status401 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('401', Status401);
|
||||
|
||||
export class status402 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status402 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 402,
|
||||
@ -30,8 +34,10 @@ export class status402 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('402', Status402);
|
||||
|
||||
export class status403 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status403 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 403,
|
||||
@ -40,8 +46,10 @@ export class status403 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('403', Status403);
|
||||
|
||||
export class status404 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status404 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 404,
|
||||
@ -50,3 +58,16 @@ export class status404 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('404', Status404);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status429 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 404,
|
||||
text: 'Too Many Requests',
|
||||
description: `The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.`
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('429', Status429);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
|
||||
export class status500 extends HttpStatus {
|
||||
export class Status500 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 500,
|
||||
@ -10,8 +10,10 @@ export class status500 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('500', Status500);
|
||||
|
||||
export class status501 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status501 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 501,
|
||||
@ -20,8 +22,10 @@ export class status501 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('501', Status501);
|
||||
|
||||
export class status502 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status502 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 502,
|
||||
@ -30,8 +34,10 @@ export class status502 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('502', Status502);
|
||||
|
||||
export class status503 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status503 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 503,
|
||||
@ -40,8 +46,10 @@ export class status503 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('503', Status503);
|
||||
|
||||
export class status504 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status504 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 504,
|
||||
@ -51,8 +59,10 @@ export class status504 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('504', Status504);
|
||||
|
||||
export class status505 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status505 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 505,
|
||||
@ -61,8 +71,10 @@ export class status505 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('505', Status505);
|
||||
|
||||
export class status506 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status506 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 506,
|
||||
@ -72,7 +84,10 @@ export class status506 extends HttpStatus {
|
||||
}
|
||||
}
|
||||
|
||||
export class status507 extends HttpStatus {
|
||||
HttpStatus.addStatus('506', Status506);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status507 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 507,
|
||||
@ -82,7 +97,10 @@ export class status507 extends HttpStatus {
|
||||
}
|
||||
}
|
||||
|
||||
export class status508 extends HttpStatus {
|
||||
HttpStatus.addStatus('507', Status507);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status508 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 508,
|
||||
@ -91,8 +109,10 @@ export class status508 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('508', Status508);
|
||||
|
||||
export class status510 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status510 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 510,
|
||||
@ -102,7 +122,8 @@ export class status510 extends HttpStatus {
|
||||
}
|
||||
}
|
||||
|
||||
export class status511 extends HttpStatus {
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status511 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 511,
|
||||
@ -113,3 +134,4 @@ export class status511 extends HttpStatus {
|
||||
});
|
||||
}
|
||||
}
|
||||
HttpStatus.addStatus('511', Status511);
|
||||
|
@ -1,9 +1,13 @@
|
||||
export type TStatusGroup = 'clientError' | 'serverError';
|
||||
|
||||
export class HttpStatus {
|
||||
protected static statusMap: {[key:string]: HttpStatus} = {};
|
||||
public static getHttpStatusByString (codeStringArg: string) {
|
||||
return HttpStatus.statusMap[codeStringArg];
|
||||
public static statusMap: {[key:string]: any} = {};
|
||||
public static addStatus (statusStringArg: string, statusArg: any) {
|
||||
HttpStatus.statusMap[statusStringArg] = statusArg;
|
||||
}
|
||||
public static getHttpStatusByString (codeStringArg: string): HttpStatus {
|
||||
const statusInstance = new (HttpStatus.statusMap[codeStringArg])();
|
||||
return statusInstance;
|
||||
}
|
||||
public code: number;
|
||||
public text: string;
|
||||
@ -12,7 +16,6 @@ export class HttpStatus {
|
||||
this.code = optionsArg.code;
|
||||
this.text = optionsArg.text;
|
||||
this.description = optionsArg.description;
|
||||
HttpStatus.statusMap[this.code.toString()] = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user