mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
fix: make index route work correctly
This commit is contained in:
committed by
Rainer Killinger
parent
24e27c1d9e
commit
fa2c9d7a88
@@ -19,7 +19,6 @@ import {
|
||||
SCRoute,
|
||||
SCValidationErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import {Validator} from '@openstapps/core-tools/lib/validate';
|
||||
import {Application, Router} from 'express';
|
||||
import PromiseRouter from 'express-promise-router';
|
||||
import {ValidationError} from 'jsonschema';
|
||||
@@ -71,9 +70,6 @@ export function createRoute<RETURNTYPE>(
|
||||
route[verb](async (req, res) => {
|
||||
|
||||
try {
|
||||
// get the core validator from the app
|
||||
const validator: Validator = req.app.get('validator');
|
||||
|
||||
// validate request
|
||||
const requestValidation = validator.validate(req.body, routeClass.requestBodyName);
|
||||
|
||||
@@ -99,13 +95,15 @@ export function createRoute<RETURNTYPE>(
|
||||
responseErrors,
|
||||
isTestEnvironment,
|
||||
);
|
||||
/*const internalServerError = new SCInternalServerErrorResponse(
|
||||
// The validation error is not caused by faulty user input, but through an error that originates somewhere in
|
||||
// the backend, therefor we use this "stacked" error.
|
||||
const internalServerError = new SCInternalServerErrorResponse(
|
||||
validationError,
|
||||
req.app.get('isTestEnvironment'),
|
||||
);*/
|
||||
res.status(validationError.statusCode);
|
||||
res.json(validationError);
|
||||
logger.warn(validationError);
|
||||
isTestEnvironment,
|
||||
);
|
||||
res.status(internalServerError.statusCode);
|
||||
res.json(internalServerError);
|
||||
logger.warn(internalServerError);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user