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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cesco69
Copy link

@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
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.

1 participant