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:
-
Navigate to the User API:
-
Start the application:
DATABASE_URL="postgresql://userapi:userpass@localhost:55433/user_api_test" yarn start
-
Observe the NestJS startup logs.
-
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.
Describe the bug
The User API registers the same routes twice during application startup.
UserControlleris declared in bothUserModuleandAppModule, even thoughAppModulealready importsUserModule.To Reproduce
Steps to reproduce the behavior:
Navigate to the User API:
cd apps/userStart the application:
DATABASE_URL="postgresql://userapi:userpass@localhost:55433/user_api_test" yarn startObserve the NestJS startup logs.
The following routes are mapped twice:
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.2Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
UserControllerandUserServiceare registered in both modules.apps/user/src/user/user.module.ts:apps/user/src/app.module.ts:Since
AppModulealready importsUserModule, the controller and service appear to be registered redundantly.