Skip to content

Commit 1d8378c

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

File tree

1 file changed

+6
-6
lines changed
  • packages/cli/src/routeGeneration/templates

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export function RegisterRoutes(server: any) {
5959
// ###########################################################################################################
6060
{{#each controllers}}
6161
{{#each actions}}
62+
const args{{../name}}_{{name}}: Record<string, TsoaRoute.ParameterSchema> = {
63+
{{#each parameters}}
64+
{{@key}}: {{{json this}}},
65+
{{/each}}
66+
};
6267
server.route({
6368
method: '{{method}}',
6469
path: '{{fullPath}}',
@@ -92,15 +97,10 @@ export function RegisterRoutes(server: any) {
9297
},
9398
{{/if}}
9499
handler: {{#if ../../iocModule}}async {{/if}}function {{../name}}_{{name}}(request: Request, h: ResponseToolkit) {
95-
const args: Record<string, TsoaRoute.ParameterSchema> = {
96-
{{#each parameters}}
97-
{{@key}}: {{{json this}}},
98-
{{/each}}
99-
};
100100

101101
let validatedArgs: any[] = [];
102102
try {
103-
validatedArgs = templateService.getValidatedArgs({ args, request, h });
103+
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, request, h });
104104
} catch (err) {
105105
const error = err as any;
106106
if (isBoom(error)) {

0 commit comments

Comments
 (0)