Skip to content

Commit 18fd7e1

Browse files
authored
perf: avoids to create every request a new object
1 parent 2defe97 commit 18fd7e1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/cli/src/routeGeneration/templates/express.hbs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export function RegisterRoutes(app: Router) {
8181

8282
{{#each controllers}}
8383
{{#each actions}}
84+
const args{{../name}}_{{name}}: Record<string, TsoaRoute.ParameterSchema> = {
85+
{{#each parameters}}
86+
{{@key}}: {{{json this}}},
87+
{{/each}}
88+
};
8489
app.{{method}}('{{fullPath}}',
8590
{{#if security.length}}
8691
authenticateMiddleware({{json security}}),
@@ -101,17 +106,12 @@ export function RegisterRoutes(app: Router) {
101106
...(fetchMiddlewares<RequestHandler>({{../name}}.prototype.{{name}})),
102107

103108
async function {{../name}}_{{name}}(request: ExRequest, response: ExResponse, next: any) {
104-
const args: Record<string, TsoaRoute.ParameterSchema> = {
105-
{{#each parameters}}
106-
{{@key}}: {{{json this}}},
107-
{{/each}}
108-
};
109109

110110
// 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
111111

112112
let validatedArgs: any[] = [];
113113
try {
114-
validatedArgs = templateService.getValidatedArgs({ args, request, response });
114+
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, request, response });
115115

116116
{{#if ../../iocModule}}
117117
const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer;

0 commit comments

Comments
 (0)