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