mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
refactor: use constructor for checking error type in SCRoute
change SCRouteHttpVerbs from type to enum
This commit is contained in:
@@ -12,7 +12,14 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute} from '../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* Index request
|
||||
@@ -29,13 +36,13 @@ export class SCIndexRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCIndexRequest';
|
||||
this.responseBodyName = 'SCIndexResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
|
||||
@@ -13,7 +13,14 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCThings} from '../../../../Classes';
|
||||
import {SCAbstractRoute} from '../../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse, SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* Request to update an existing thing
|
||||
@@ -29,14 +36,14 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCNotFoundErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'PUT';
|
||||
this.method = SCRouteHttpVerbs.PUT;
|
||||
this.obligatoryParameters = {
|
||||
TYPE: 'SCThingTypes',
|
||||
UID: 'SCUuid',
|
||||
|
||||
@@ -12,8 +12,16 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute} from '../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCUuid} from '../../../types/UUID';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* Request to check the availability of books
|
||||
@@ -60,14 +68,14 @@ export class SCBookAvailabilityRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCNotFoundErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCBookAvailabilityRequest';
|
||||
this.responseBodyName = 'SCBookAvailabilityResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
|
||||
@@ -12,9 +12,16 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute} from '../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCThingType} from '../../../Thing';
|
||||
import {SCISO8601Date} from '../../../types/Time';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* A bulk request
|
||||
@@ -60,13 +67,13 @@ export class SCBulkRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCBulkRequest';
|
||||
this.responseBodyName = 'SCBulkResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
|
||||
@@ -13,7 +13,15 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCThings} from '../../../../Classes';
|
||||
import {SCAbstractRoute} from '../../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* Request to add a thing to a bulk
|
||||
@@ -28,14 +36,14 @@ export class SCBulkAddRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCNotFoundErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.obligatoryParameters = {
|
||||
UID: 'SCUuid',
|
||||
};
|
||||
|
||||
@@ -12,7 +12,15 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute} from '../../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* Request to change the bulk state to done (close the bulk process)
|
||||
@@ -28,14 +36,14 @@ export class SCBulkDoneRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCNotFoundErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.obligatoryParameters = {
|
||||
UID: 'SCUuid',
|
||||
};
|
||||
|
||||
@@ -12,8 +12,15 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute} from '../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCMessage} from '../../../things/Message';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* User feedback
|
||||
@@ -34,13 +41,13 @@ export class SCFeedbackRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCFeedbackRequest';
|
||||
this.responseBodyName = 'SCFeedbackResponse';
|
||||
this.statusCodeSuccess = 204;
|
||||
|
||||
@@ -12,7 +12,15 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute} from '../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCTooManyRequestsErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../errors/ErrorResponse';
|
||||
import {SCSearchQuery} from './SearchRequest';
|
||||
|
||||
/**
|
||||
@@ -35,14 +43,14 @@ export class SCMultiSearchRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCTooManyRequestsErrorResponse',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCTooManyRequestsErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCMultiSearchRequest';
|
||||
this.responseBodyName = 'SCMultiSearchResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
|
||||
@@ -12,9 +12,16 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute} from '../../../Route';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCSearchFilter} from '../../../types/filters/Abstract';
|
||||
import {SCSearchSort} from '../../../types/sorts/Abstract';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
} from '../../errors/ErrorResponse';
|
||||
|
||||
/**
|
||||
* A search request
|
||||
@@ -61,13 +68,13 @@ export class SCSearchRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
'SCInternalServerErrorResponse',
|
||||
'SCMethodNotAllowedErrorResponse',
|
||||
'SCSyntaxError',
|
||||
'SCUnsupportedMediaTypeErrorResponse',
|
||||
'SCValidationErrorResponse',
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = 'POST';
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCSearchRequest';
|
||||
this.responseBodyName = 'SCSearchResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
|
||||
Reference in New Issue
Block a user