A method handler is interfering into another handler with same name in another controller.
See original GitHub issueBug Report
Current behavior
I had two controllers into two differnt folders and differnt modules, Both of them has a method with same create
name.
/admin/entity.controller.ts
@Controller("admin")
export class EntityController{
@Post()
public async create(@Request() request: any): Promise<List> {
console.log("request", request) // Logs the Body {"name": "test"} instead of request.
}
}
/user/entity.ontroller.ts
@Controller("user")
export class EntityController{
@Post()
public async create(@Body() entity: Entity) {
console.log("entity", entity) // logs the body {"name": "test"}
}
}
When I do post the following in both routes: {"name": "test"}
,
curl -X POST http://localhost:3000/admin/ -d '{"name":"test"}'
curl -X POST http://localhost:3000/user/ -d '{"name":"test"}'
It happens that admin
create()
method logs the body
part, not the requests
as expected.
It seems to be that the definition of the user
controller is interfering into the admin
controller and making it to do not work properly.
Environment
- Nest version: 6.0.0
- Node version: v10.15.1
- Platform: Windows 10
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
NestJS - A method handler is interfering into ... - Stack Overflow
I had two controllers into two differnt folders into two different modules, Both of them has a method with same create name.
Read more >Lightning Components: Unable to handle an event
Now i am able to handle the event if put a handler in the same component, but if i try to handle the...
Read more >Handling Events :: Eloquent JavaScript
Calling its addEventListener method registers the second argument to be called whenever the event described by its first argument occurs. Events and DOM...
Read more >Interceptors | NestJS - A progressive Node.js framework
The CallHandler interface implements the handle() method, which you can use to invoke the route handler method at some point in your interceptor....
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
When your code contains entities that are too large for the JavaScript engine (e.g. too many switch cases, too large array initializers, too ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please, provide a minimal repository which reproduces your issue.
same issue @kamilmysliwiec there is a repo https://github.com/xyunsh/samenamed
http://localhost:3000/user1/details controller named UserController -> /user1/details http://localhost:3000/user2/details controller named UserController -> get error moduleb’s UserController not work.
http://localhost:3000/usera/details controller named UseraController-> /usera/details http://localhost:3000/userb/details controller named UserbController-> /userb/details modulea & moudleb’s controllers both work well.