#Hexagonal Architecture - Unable to receive url parameters, request body, or request object

6 messages · Page 1 of 1 (latest)

vocal fulcrum
#

For starters, here are the goods - this is a complete repex of what i'm working with: https://github.com/vbuongiovanni/hexagonal-arch-issue-repex

Context:
I am working through NestJs's advanced architecture course... Evidently, it it is a bit over my head. I am trying to implement the hexagonal architecture, but I am running into an issue where the controller is not receiving the request object (url params, request body, and request object all come back as undefined). What's odd is that I can confirm that the params and url are both hitting the app module because they ARE defined in middleware that I added during the debugging process.

Issue Reproduction

Attempt to make a post request (with or without a parameter) and observe the console logs show that the alarms.controller reads both (as well as the request object) as undefined. This is despite the fact that both ARE defined, as shown in the middleware.

curl command for endpoint with parameter:

curl -X POST http://localhost:3000/alarms -H "Content-Type: application/json" -d '{"name": "Test Alarm", "severity": "high"}'

curl command for call without parameter:

curl -X POST http://localhost:3000/alarms/123 -H "Content-Type: application/json" -d '{"name": "Test Alarm", "severity": "high"}'

I am reasonably certain that I didn't configure something correctly, but I have no idea what. I went through the prior videos and confirmed that all my code aligns with the videos.. but still now no avail.

For the love of god, can someone please point me in the right direction?

Thank you in advance for any help or input you can provide.

GitHub

Contribute to vbuongiovanni/hexagonal-arch-issue-repex development by creating an account on GitHub.

native sundial
#

There's a chance this is due to the version of reflect-metadata. Can you run npm ls reflect-metadata? I think that's the right command

vocal fulcrum
#

I should have mentioned, I did try to run through and update nestjs, but that didn't seem to have an impact, so I reversed the changes to keep everything consistent with my other projects.

Here is the output of npm ls reflect-metadata:

native sundial
#

Yep. That's what I thought. Run npm i reflect-metadata@^0.2.0

vocal fulcrum
#

Sweet jesus! You're a miracle worker. Thank you so much!

#

I love the work you guys do btw. thank you for everything