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): void { 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; } }