refactor: remove unused code

This commit is contained in:
Jovan Krunić
2020-09-28 15:23:14 +02:00
committed by Rainer Killinger
parent d3955b3cdd
commit 60b689f28c
3 changed files with 2 additions and 29 deletions

View File

@@ -31,11 +31,6 @@ export const bulkAddRouter = createRoute<SCBulkAddRequest, SCBulkAddResponse>(
bulkRouteModel,
async (request, app, params) => {
// TODO: DELETE as not used
if (typeof params === 'undefined' || typeof params.UID !== 'string') {
throw new Error('UID of Bulk was not given, but route with obligatory parameter was called');
}
const bulkMemory: BulkStorage = app.get('bulk');
const bulk = await bulkMemory.read(params.UID);

View File

@@ -31,11 +31,6 @@ export const bulkDoneRouter = createRoute<SCBulkDoneRequest, SCBulkDoneResponse>
bulkDoneRouteModel,
async (_request, app, params) => {
// TODO: DELETE as not used
if (typeof params === 'undefined' || typeof params.UID !== 'string') {
throw new Error('UID of Bulk was not given, but route with obligatory parameter was called');
}
const bulkMemory: BulkStorage = app.get('bulk');
const bulk = await bulkMemory.read(params.UID);

View File

@@ -29,7 +29,7 @@ import {isHttpMethod} from './http-types';
/**
* Creates a router from a route class and a handler function which implements the logic
*
* The given router performs a request and respone validation, sets status codes and checks if the given handler
* The given router performs a request and response validation, sets status codes and checks if the given handler
* only returns errors that are allowed for the client to see
*
* @param routeClass Model of a route
@@ -39,7 +39,7 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
routeClass: SCRoute,
handler: (
validatedBody: REQUESTTYPE,
app: Application, params?: { [parameterName: string]: string; },
app: Application, params: { [parameterName: string]: string; },
) => Promise<RETURNTYPE>,
): Router {
// create router
@@ -49,23 +49,6 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
// the given type has no index signature so we have to cast to get the IRouteHandler when a HTTP method is given
const route = router.route(routeClass.urlFragment);
// get route parameters (path parameters) TODO: DELETE as not used
if (Array.isArray(routeClass.obligatoryParameters) && routeClass.obligatoryParameters.length > 0) {
routeClass.obligatoryParameters.forEach((parameterName) => {
router.param(parameterName, async (req, _res, next, parameterValue: string) => {
if (typeof req.params === 'undefined') {
req.params = {};
}
// set parameter values on request object
req.params[parameterName] = parameterValue;
// hand over the request to the next handler (our method route handler)
next();
});
});
}
const verb = routeClass.method.toLowerCase();
// check if route has a valid http verb