/* tslint:disable */ /* eslint-disable */ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { Controller, ValidationService, FieldErrors, ValidateError, TsoaRoute, HttpStatusCodeLiteral, TsoaResponse, fetchMiddlewares } from '@tsoa/runtime'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { OrgRootController } from './controllers/OrgRootController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { AppController } from './controllers/MyController'; import { expressAuthentication } from './middlewares/auth'; // @ts-ignore - no great way to install types from subpackage import type { RequestHandler, Router } from 'express'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa const models: TsoaRoute.Models = { "OrgRootRank": { "dataType": "refEnum", "enums": ["department","office","division","section"], }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "CreateOrgRoot": { "dataType": "refObject", "properties": { "orgRootName": {"dataType":"string","required":true}, "orgRootShortName": {"dataType":"string","required":true}, "orgRootCode": {"dataType":"string","required":true}, "orgRootRank": {"ref":"OrgRootRank","required":true}, "orgRootOrder": {"dataType":"double","required":true}, "orgRootPhoneEx": {"dataType":"string","required":true}, "orgRootPhoneIn": {"dataType":"string","required":true}, "orgRootFax": {"dataType":"string","required":true}, "orgRootIsNormal": {"dataType":"boolean","required":true}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa }; const validationService = new ValidationService(models); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa export function RegisterRoutes(app: Router) { // ########################################################################################################### // NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look // Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa // ########################################################################################################### app.post('/organization/root', ...(fetchMiddlewares(OrgRootController)), ...(fetchMiddlewares(OrgRootController.prototype.create)), function OrgRootController_create(request: any, response: any, next: any) { const args = { requestBody: {"in":"body","name":"requestBody","required":true,"ref":"CreateOrgRoot"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa let validatedArgs: any[] = []; try { validatedArgs = getValidatedArgs(args, request, response); const controller = new OrgRootController(); const promise = controller.create.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.put('/organization/root/:id', ...(fetchMiddlewares(OrgRootController)), ...(fetchMiddlewares(OrgRootController.prototype.update)), function OrgRootController_update(request: any, response: any, next: any) { const args = { id: {"in":"path","name":"id","required":true,"dataType":"string"}, requestBody: {"in":"body","name":"requestBody","required":true,"ref":"CreateOrgRoot"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa let validatedArgs: any[] = []; try { validatedArgs = getValidatedArgs(args, request, response); const controller = new OrgRootController(); const promise = controller.update.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/hello', authenticateMiddleware([{"bearerAuth":[]}]), ...(fetchMiddlewares(AppController)), ...(fetchMiddlewares(AppController.prototype.GET)), function AppController_GET(request: any, response: any, next: any) { const args = { }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa let validatedArgs: any[] = []; try { validatedArgs = getValidatedArgs(args, request, response); const controller = new AppController(); const promise = controller.GET.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa function authenticateMiddleware(security: TsoaRoute.Security[] = []) { return async function runAuthenticationMiddleware(request: any, _response: any, next: any) { // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa // keep track of failed auth attempts so we can hand back the most // recent one. This behavior was previously existing so preserving it // here const failedAttempts: any[] = []; const pushAndRethrow = (error: any) => { failedAttempts.push(error); throw error; }; const secMethodOrPromises: Promise[] = []; for (const secMethod of security) { if (Object.keys(secMethod).length > 1) { const secMethodAndPromises: Promise[] = []; for (const name in secMethod) { secMethodAndPromises.push( expressAuthentication(request, name, secMethod[name]) .catch(pushAndRethrow) ); } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa secMethodOrPromises.push(Promise.all(secMethodAndPromises) .then(users => { return users[0]; })); } else { for (const name in secMethod) { secMethodOrPromises.push( expressAuthentication(request, name, secMethod[name]) .catch(pushAndRethrow) ); } } } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa try { request['user'] = await Promise.any(secMethodOrPromises); next(); } catch(err) { // Show most recent error as response const error = failedAttempts.pop(); error.status = error.status || 401; next(error); } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa } } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa function isController(object: any): object is Controller { return 'getHeaders' in object && 'getStatus' in object && 'setStatus' in object; } function promiseHandler(controllerObj: any, promise: any, response: any, successStatus: any, next: any) { return Promise.resolve(promise) .then((data: any) => { let statusCode = successStatus; let headers; if (isController(controllerObj)) { headers = controllerObj.getHeaders(); statusCode = controllerObj.getStatus() || statusCode; } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa returnHandler(response, statusCode, data, headers) }) .catch((error: any) => next(error)); } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa function returnHandler(response: any, statusCode?: number, data?: any, headers: any = {}) { if (response.headersSent) { return; } Object.keys(headers).forEach((name: string) => { response.set(name, headers[name]); }); if (data && typeof data.pipe === 'function' && data.readable && typeof data._read === 'function') { response.status(statusCode || 200) data.pipe(response); } else if (data !== null && data !== undefined) { response.status(statusCode || 200).json(data); } else { response.status(statusCode || 204).end(); } } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa function responder(response: any): TsoaResponse { return function(status, data, headers) { returnHandler(response, status, data, headers); }; }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa function getValidatedArgs(args: any, request: any, response: any): any[] { const fieldErrors: FieldErrors = {}; const values = Object.keys(args).map((key) => { const name = args[key].name; switch (args[key].in) { case 'request': return request; case 'query': return validationService.ValidateParam(args[key], request.query[name], name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); case 'queries': return validationService.ValidateParam(args[key], request.query, name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); case 'path': return validationService.ValidateParam(args[key], request.params[name], name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); case 'header': return validationService.ValidateParam(args[key], request.header(name), name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); case 'body': return validationService.ValidateParam(args[key], request.body, name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); case 'body-prop': return validationService.ValidateParam(args[key], request.body[name], name, fieldErrors, 'body.', {"noImplicitAdditionalProperties":"throw-on-extras"}); case 'formData': if (args[key].dataType === 'file') { return validationService.ValidateParam(args[key], request.file, name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); } else if (args[key].dataType === 'array' && args[key].array.dataType === 'file') { return validationService.ValidateParam(args[key], request.files, name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); } else { return validationService.ValidateParam(args[key], request.body[name], name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"throw-on-extras"}); } case 'res': return responder(response); } }); if (Object.keys(fieldErrors).length > 0) { throw new ValidateError(fieldErrors, ''); } return values; } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa } // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa