This repository has been archived on 2020-08-13. You can view files and clone it, but cannot push or open issues or pull requests.
requestor/lib/classes/Status.ts
2020-04-09 10:31:15 +02:00

48 lines
869 B
TypeScript

import http from '@scode/consts';
export default class Status {
private _status = -1;
public get status (): number {
if (this._status === -1)
throw new Error ('status undefined');
return this._status;
}
public set status (value: number) {
this._status = value;
}
public get has_status (): boolean {
return this._status !== -1;
}
/*
* Status setters
*/
public ok (): void {
this._status = http.status_ok;
}
public ok_no_content (): void {
this._status = http.status_ok_no_content;
}
public bad_request (): void {
this._status = http.status_bad_request;
}
public unauthorized (): void {
this._status = http.status_unauthorized;
}
public forbidden (): void {
this._status = http.status_forbidden;
}
public not_found (): void {
this._status = http.status_not_found;
}
}