/* 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 { ApiClientController } from './../../../routes/v3/controllers/admin/ApiClient/ApiClientController'; // 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 { DataIngestionController } from './../../../routes/v3/controllers/DataIngestion/DataIngestionController'; // 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 { GoogleProductsController } from './../../../routes/v3/controllers/GoogleProducts/GoogleProductsController'; // 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 { RawRetailerController } from './../../../routes/v3/controllers/RawRetailer/RawRetailerController'; // 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 { JobQueueController } from './../../../routes/v3/controllers/JobQueue/JobQueueController'; import { expressAuthentication } from './../../../routes/authentication'; // @ts-ignore - no great way to install types from subpackage const promiseAny = require('promise.any'); import type { RequestHandler } from 'express'; import * as express 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 = { "ApiKeyPayload": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"apiKey":{"dataType":"string","required":true}},"validators":{}}, }, // 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 "GenerateApiKeyInput": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"username":{"dataType":"string","required":true}},"validators":{}}, }, // 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 "CreateProductPayload": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"status":{"dataType":"string","required":true}},"validators":{}}, }, // 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 "CreateProductInput": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"productIds":{"dataType":"array","array":{"dataType":"string"}},"googleShoppingUrl":{"dataType":"string"},"retailerUrls":{"dataType":"array","array":{"dataType":"string"}},"ingestionId":{"dataType":"string"}},"validators":{}}, }, // 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 "GoogleProductsPayload": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"status":{"dataType":"string","required":true}},"validators":{}}, }, // 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 "RawGoogleShoppingOffersDataV1": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"offers":{"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"price":{"dataType":"double","required":true},"url":{"dataType":"string","required":true}}},"required":true},"description":{"dataType":"string"}},"validators":{}}, }, // 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 "GoogleProductsInput": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"productIds":{"dataType":"array","array":{"dataType":"string"}},"data":{"ref":"RawGoogleShoppingOffersDataV1","required":true},"shoppingId":{"dataType":"string","required":true},"ingestionID":{"dataType":"string"}},"validators":{}}, }, // 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 "RawRetailerPayload": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string"},"status":{"dataType":"union","subSchemas":[{"dataType":"enum","enums":["success"]},{"dataType":"enum","enums":["failure"]}],"required":true}},"validators":{}}, }, // 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 "RawRetailerDataV1": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"category":{"dataType":"string"},"url":{"dataType":"string","required":true},"imageUrls":{"dataType":"array","array":{"dataType":"string"}},"distributorSKU":{"dataType":"string"},"distributor":{"dataType":"string"},"isAvailable":{"dataType":"boolean"},"price":{"dataType":"double","required":true},"name":{"dataType":"string"},"description":{"dataType":"string"},"annotations":{"dataType":"string"},"colorCode":{"dataType":"string"},"dimensions":{"dataType":"string"},"asin":{"dataType":"string"},"id":{"dataType":"string"}},"validators":{}}, }, // 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 "RawRetailerInput": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"data":{"dataType":"array","array":{"dataType":"refAlias","ref":"RawRetailerDataV1"},"required":true},"productIds":{"dataType":"array","array":{"dataType":"string"}},"ingestionID":{"dataType":"string"}},"validators":{}}, }, // 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 "AddJobPayload": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"id":{"dataType":"string","required":true}},"validators":{}}, }, // 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 "JobKind": { "dataType": "refEnum", "enums": ["BULK_FETCH_LATEST_PAGE_1","QUEUE_PAGES_NEEDING_UPDATES_1","QUEUE_PRODUCTS_NEEDING_UPDATES_1","UPDATE_GOOGLE_SHOPPING_OFFERS_PRICE_1","FETCH_RETAILER_INFO_1","FETCH_GOOGLE_SHOPPING_INFO_1"], }, // 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 "AddJobInput": { "dataType": "refAlias", "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"data":{"dataType":"any","required":true},"kind":{"ref":"JobKind","required":true}},"validators":{}}, }, // 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: express.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('/api-keys', authenticateMiddleware([{"basic":["ADMIN"]}]), ...(fetchMiddlewares(ApiClientController)), ...(fetchMiddlewares(ApiClientController.prototype.generateApiKey)), function ApiClientController_generateApiKey(request: any, response: any, next: any) { const args = { requestBody: {"in":"body","name":"requestBody","required":true,"ref":"GenerateApiKeyInput"}, notFoundResponse: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, alreadyExistsResponse: {"in":"res","name":"409","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // 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 ApiClientController(); const promise = controller.generateApiKey.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, 201, 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.delete('/api-keys/:username', authenticateMiddleware([{"basic":["ADMIN"]}]), ...(fetchMiddlewares(ApiClientController)), ...(fetchMiddlewares(ApiClientController.prototype.revokeApiKey)), function ApiClientController_revokeApiKey(request: any, response: any, next: any) { const args = { username: {"in":"path","name":"username","required":true,"dataType":"string"}, notFoundResponse: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, conflictResponse: {"in":"res","name":"409","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // 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 ApiClientController(); const promise = controller.revokeApiKey.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, 204, 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.post('/aggregate-products', authenticateMiddleware([{"basic":["ADMIN"]}]), ...(fetchMiddlewares(DataIngestionController)), ...(fetchMiddlewares(DataIngestionController.prototype.createAggregateProduct)), function DataIngestionController_createAggregateProduct(request: any, response: any, next: any) { const args = { requestBody: {"in":"body","name":"requestBody","required":true,"ref":"CreateProductInput"}, invalidInput: {"in":"res","name":"422","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // 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 DataIngestionController(); const promise = controller.createAggregateProduct.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, 201, 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.post('/aggregate-products/batch', authenticateMiddleware([{"basic":["ADMIN"]}]), ...(fetchMiddlewares(DataIngestionController)), ...(fetchMiddlewares(DataIngestionController.prototype.batchCreateAggregateProducts)), function DataIngestionController_batchCreateAggregateProducts(request: any, response: any, next: any) { const args = { requestBody: {"in":"body","name":"requestBody","required":true,"dataType":"array","array":{"dataType":"refAlias","ref":"CreateProductInput"}}, invalidInput: {"in":"res","name":"422","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reasons":{"dataType":"array","array":{"dataType":"string"},"required":true}}}, }; // 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 DataIngestionController(); const promise = controller.batchCreateAggregateProducts.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, 201, 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.post('/google-products', authenticateMiddleware([{"basic":["ADMIN"]}]), ...(fetchMiddlewares(GoogleProductsController)), ...(fetchMiddlewares(GoogleProductsController.prototype.googleProducts)), function GoogleProductsController_googleProducts(request: any, response: any, next: any) { const args = { requestBody: {"in":"body","name":"requestBody","required":true,"ref":"GoogleProductsInput"}, }; // 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 GoogleProductsController(); const promise = controller.googleProducts.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, 201, 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.post('/raw-retailers', authenticateMiddleware([{"basic":["ADMIN"]}]), ...(fetchMiddlewares(RawRetailerController)), ...(fetchMiddlewares(RawRetailerController.prototype.rawRetailers)), function RawRetailerController_rawRetailers(request: any, response: any, next: any) { const args = { requestBody: {"in":"body","name":"requestBody","required":true,"ref":"RawRetailerInput"}, failed: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, invalidInput: {"in":"res","name":"422","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // 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 RawRetailerController(); const promise = controller.rawRetailers.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, 201, 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.post('/jobqueue', ...(fetchMiddlewares(JobQueueController)), ...(fetchMiddlewares(JobQueueController.prototype.jobQueues)), function JobQueueController_jobQueues(request: any, response: any, next: any) { const args = { requestBody: {"in":"body","name":"requestBody","required":true,"ref":"AddJobInput"}, }; // 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 JobQueueController(); const promise = controller.jobQueues.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 promiseAny(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') { 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":"silently-remove-extras"}); case 'path': return validationService.ValidateParam(args[key], request.params[name], name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"silently-remove-extras"}); case 'header': return validationService.ValidateParam(args[key], request.header(name), name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"silently-remove-extras"}); case 'body': return validationService.ValidateParam(args[key], request.body, name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"silently-remove-extras"}); case 'body-prop': return validationService.ValidateParam(args[key], request.body[name], name, fieldErrors, 'body.', {"noImplicitAdditionalProperties":"silently-remove-extras"}); case 'formData': if (args[key].dataType === 'file') { return validationService.ValidateParam(args[key], request.file, name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"silently-remove-extras"}); } else if (args[key].dataType === 'array' && args[key].array.dataType === 'file') { return validationService.ValidateParam(args[key], request.files, name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"silently-remove-extras"}); } else { return validationService.ValidateParam(args[key], request.body[name], name, fieldErrors, undefined, {"noImplicitAdditionalProperties":"silently-remove-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