mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
refactor: use constructor for checking error type in SCRoute
change SCRouteHttpVerbs from type to enum
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
/**
|
||||
* Possible HTTP verbs for routes
|
||||
*/
|
||||
import {SCErrorResponse} from './protocol/errors/ErrorResponse';
|
||||
import {SCBookAvailabilityRequest} from './protocol/routes/bookAvailability/BookAvailabilityRequest';
|
||||
import {SCBookAvailabilityResponse} from './protocol/routes/bookAvailability/BookAvailabilityResponse';
|
||||
import {SCBulkRequest} from './protocol/routes/bulk/BulkRequest';
|
||||
@@ -35,7 +36,19 @@ import {SCThingUpdateRequest} from './protocol/routes/TYPE/UID/ThingUpdateReques
|
||||
import {SCThingUpdateResponse} from './protocol/routes/TYPE/UID/ThingUpdateResponse';
|
||||
import {SCMap} from './types/Map';
|
||||
|
||||
export type SCRouteHttpVerbs = 'GET' | 'POST' | 'PUT';
|
||||
/**
|
||||
* Possible Verbs for HTTP requests
|
||||
*/
|
||||
export enum SCRouteHttpVerbs {
|
||||
GET = 'GET',
|
||||
POST = 'POST',
|
||||
PUT = 'PUT',
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor of an error response
|
||||
*/
|
||||
export type SCErrorResponseConstructor = new (...args: any) => SCErrorResponse;
|
||||
|
||||
/**
|
||||
* A description of a route
|
||||
@@ -44,7 +57,7 @@ export interface SCRoute {
|
||||
/**
|
||||
* A map of names of possible errors that can be returned by the route with their appropriate status codes
|
||||
*/
|
||||
errorNames: string[];
|
||||
errorNames: SCErrorResponseConstructor[];
|
||||
|
||||
/**
|
||||
* HTTP verb to use to request the route
|
||||
@@ -81,10 +94,8 @@ export interface SCRoute {
|
||||
* An abstract route
|
||||
*/
|
||||
export abstract class SCAbstractRoute implements SCRoute {
|
||||
errorNames = [
|
||||
'SCErrorResponse',
|
||||
];
|
||||
method: SCRouteHttpVerbs = 'GET';
|
||||
errorNames: SCErrorResponseConstructor[] = [];
|
||||
method: SCRouteHttpVerbs = SCRouteHttpVerbs.GET;
|
||||
obligatoryParameters?: SCMap<string>;
|
||||
requestBodyName = 'any';
|
||||
responseBodyName = 'any';
|
||||
|
||||
Reference in New Issue
Block a user