providing labels for status codes
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { CtlResponse } from "./types";
|
||||
import { CtlResponse, StatusCode } from "./types";
|
||||
|
||||
export default class ControllerResponse<T> implements CtlResponse<T> {
|
||||
ok: boolean
|
||||
code: number
|
||||
data: T | T[] | string
|
||||
code: StatusCode
|
||||
data: T | string
|
||||
|
||||
constructor(ok: boolean, code: number, data: T | T[] | string) {
|
||||
constructor(ok: boolean, code: StatusCode, data: T | string) {
|
||||
this.ok = ok
|
||||
this.code = code
|
||||
this.data = data
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
export interface CtlResponse<T> {
|
||||
ok: boolean
|
||||
code: number
|
||||
data: T | T[] | string
|
||||
data: T | string
|
||||
}
|
||||
|
||||
export enum StatusCode {
|
||||
OK = 200,
|
||||
NewContent = 201,
|
||||
NoContent = 204,
|
||||
NotModified = 304,
|
||||
BadRequest = 400,
|
||||
Unauthorized = 401,
|
||||
Forbidden = 403,
|
||||
NotFound = 404,
|
||||
ServerError = 500
|
||||
}
|
||||
Reference in New Issue
Block a user