/**
|
|
* The basic response schema
|
|
*/
|
|
export interface IResponse<T> {
|
|
result?: T,
|
|
status : string
|
|
}
|
|
|
|
/**
|
|
* Supported status codes
|
|
*/
|
|
export enum Status {
|
|
Ok = 200,
|
|
BadRequest = 400,
|
|
Unauthorized = 401,
|
|
Forbidden = 403,
|
|
NotFound = 404,
|
|
Conflict = 409,
|
|
Gone = 410,
|
|
PayloadTooLarge = 413,
|
|
UnprocessableEntity = 422,
|
|
InternalServerError = 500
|
|
}
|
|
|
|
/**
|
|
* Create a response
|
|
*/
|
|
export function statusMessage(status: Status): string {
|
|
switch(status) {
|
|
case Status.Ok:
|
|
return "OK"
|
|
case Status.BadRequest:
|
|
return "Bad Request";
|
|
case Status.Unauthorized:
|
|
return "Unauthorized";
|
|
case Status.Forbidden:
|
|
return "Forbidden";
|
|
case Status.NotFound:
|
|
return "Not Found";
|
|
case Status.Conflict:
|
|
return "Conflict";
|
|
case Status.Gone:
|
|
return "Gone";
|
|
case Status.PayloadTooLarge:
|
|
return "Payload Too Large";
|
|
case Status.UnprocessableEntity:
|
|
return "Unprocessable Entity";
|
|
case Status.InternalServerError:
|
|
return "Internal Server Error";
|
|
}
|
|
}
|