mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
refactor: remove unused code
This commit is contained in:
committed by
Rainer Killinger
parent
d3955b3cdd
commit
60b689f28c
@@ -31,11 +31,6 @@ export const bulkAddRouter = createRoute<SCBulkAddRequest, SCBulkAddResponse>(
|
|||||||
bulkRouteModel,
|
bulkRouteModel,
|
||||||
async (request, app, params) => {
|
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 bulkMemory: BulkStorage = app.get('bulk');
|
||||||
const bulk = await bulkMemory.read(params.UID);
|
const bulk = await bulkMemory.read(params.UID);
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,6 @@ export const bulkDoneRouter = createRoute<SCBulkDoneRequest, SCBulkDoneResponse>
|
|||||||
bulkDoneRouteModel,
|
bulkDoneRouteModel,
|
||||||
async (_request, app, params) => {
|
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 bulkMemory: BulkStorage = app.get('bulk');
|
||||||
const bulk = await bulkMemory.read(params.UID);
|
const bulk = await bulkMemory.read(params.UID);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import {isHttpMethod} from './http-types';
|
|||||||
/**
|
/**
|
||||||
* Creates a router from a route class and a handler function which implements the logic
|
* 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
|
* only returns errors that are allowed for the client to see
|
||||||
*
|
*
|
||||||
* @param routeClass Model of a route
|
* @param routeClass Model of a route
|
||||||
@@ -39,7 +39,7 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
|
|||||||
routeClass: SCRoute,
|
routeClass: SCRoute,
|
||||||
handler: (
|
handler: (
|
||||||
validatedBody: REQUESTTYPE,
|
validatedBody: REQUESTTYPE,
|
||||||
app: Application, params?: { [parameterName: string]: string; },
|
app: Application, params: { [parameterName: string]: string; },
|
||||||
) => Promise<RETURNTYPE>,
|
) => Promise<RETURNTYPE>,
|
||||||
): Router {
|
): Router {
|
||||||
// create 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
|
// 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);
|
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();
|
const verb = routeClass.method.toLowerCase();
|
||||||
|
|
||||||
// check if route has a valid http verb
|
// check if route has a valid http verb
|
||||||
|
|||||||
Reference in New Issue
Block a user