|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- interface Response<T extends {} = {}> {
- status: number,
- data?: T,
- }
-
- interface ErrorResponse extends Response {
- message: string,
- }
-
- type ResponseParams<T extends {} = {}> = {
- message?: string,
- data?: T,
- }
-
- export class NotFound implements ErrorResponse {
- public readonly status = 404
- public readonly message: string
- constructor(params: ResponseParams) {
- this.message = params.message
- }
- }
-
- export class Created<T extends {}> implements Response {
- public readonly status = 201
- public readonly data: T
- constructor(params: ResponseParams<T>) {
- this.data = params.data
- }
- }
-
- export class Saved<T extends {}> implements Response {
- public readonly status = 200
- public readonly data: T
- constructor(params: ResponseParams<T>) {
- this.data = params.data
- }
- }
-
- export class Retrieved<T extends {}> implements Response {
- public readonly status = 200
- public readonly data: T
- constructor(params: ResponseParams<T>) {
- this.data = params.data
- }
- }
-
- export class Destroyed implements Response {
- public readonly status = 204
- }
|