refactor: use constructor for checking error type in SCRoute

change SCRouteHttpVerbs from type to enum
This commit is contained in:
Wieland Schöbl
2019-02-13 16:20:31 +01:00
parent f9c357fccf
commit e2ff4f4ec6
10 changed files with 152 additions and 74 deletions

View File

@@ -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;