Skip to content

User API routes are registered twice during startup #815

Description

@namrata-x

Describe the bug
The User API registers the same routes twice during application startup. UserController is declared in both UserModule and AppModule, even though AppModule already imports UserModule.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to the User API:

    cd apps/user
  2. Start the application:

    DATABASE_URL="postgresql://userapi:userpass@localhost:55433/user_api_test" yarn start
  3. Observe the NestJS startup logs.

  4. The following routes are mapped twice:

    Mapped {/login, POST} route
    Mapped {/register, POST} route
    Mapped {/healthz, GET} route
    Mapped {/me, GET} route
    
    Mapped {/login, POST} route
    Mapped {/register, POST} route
    Mapped {/healthz, GET} route
    Mapped {/me, GET} route
    

Expected behavior
Each User API route should be registered and mapped only once during application startup.

Screenshots
N/A. Reproduced using the application startup logs in the terminal.

Node.js version
Node.js v20.20.2

Desktop (please complete the following information):

  • OS: macOS
  • Browser: N/A — reproduced using the terminal
  • Version: N/A

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser: N/A
  • Version: N/A

Additional context
UserController and UserService are registered in both modules.

apps/user/src/user/user.module.ts:

controllers: [UserController],
providers: [UserService],

apps/user/src/app.module.ts:

imports: [UserModule, ...],
controllers: [UserController],
providers: [UserService, AuthService],

Since AppModule already imports UserModule, the controller and service appear to be registered redundantly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions