Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: avoids to create on every request a new object of args #1710

Merged
merged 4 commits into from
Dec 8, 2024

Conversation

cesco69
Copy link
Contributor

@cesco69 cesco69 commented Oct 30, 2024

tsoa on every request create a new object of "args". Eg.:

app.get('/getInvalidTokens',
    async function UsersController_getInvalidTokens(request: ExRequest, response: ExResponse, next: any) {
    
    //    👇 
    const args: Record<string, TsoaRoute.ParameterSchema> = {
        req: {"in":"request","name":"req","required":true,"dataType":"object"},
    };

    // 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 = templateService.getValidatedArgs({ args, request, response });

This PR create one time "args" object (out of api handler). Eg:

//    👇 
const argsUsersController_getInvalidTokens: Record<string, TsoaRoute.ParameterSchema> = {
    req: {"in":"request","name":"req","required":true,"dataType":"object"},
};
app.get('/getInvalidTokens',
    async function UsersController_getInvalidTokens(request: ExRequest, response: ExResponse, 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

    let validatedArgs: any[] = [];
    try {
       //                                                    👇 
        validatedArgs = templateService.getValidatedArgs({ args: argsUsersController_getInvalidTokens, request, response });

@cesco69 cesco69 changed the title perf: avoids to create every request a new object perf: avoids to create on every request a new object of args Oct 30, 2024
@WoH WoH requested a review from jackey8616 October 31, 2024 13:19
@WoH WoH force-pushed the master branch 2 times, most recently from 30cc104 to 82b61ec Compare December 8, 2024 16:44
@WoH WoH merged commit fbfd0ca into lukeautry:master Dec 8, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants