Closed leahtopchik closed 1 year ago
Hi @leahtopchik
Seems like you're using swc
, which means the emitDecoratorMetadata
flag needs to be added to the tsconfig file, as explained here: https://next-api-decorators.vercel.app/docs/#using-with-swc
Let me know if this solves the problem you're having. If not, having a minimal reproducible example will be very much beneficial for us.
Hi, Thanks for the quick response. This didn't solve the problem, unfortunately. I will try and pull out a minimal example that's runnable!
Here's the stack trace I'm seeing in my logs - I'm working on an example but I'm getting errors on the simple project I tried to spin up. Let me know if you have any ideas:
BadRequestException: email must be an email
at Object.validateObject (/home/***/webapp/node_modules/next-api-decorators/dist/internals/validateObject.js:29:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /home/***/webapp/node_modules/next-api-decorators/dist/internals/handler.js:59:25
at async Promise.all (index 0)
at async NewsletterSubscribeHandler.runMainLayer (/home/***/webapp/node_modules/next-api-decorators/dist/internals/handler.js:41:24)
at async descriptor.value (/home/***/webapp/node_modules/next-api-decorators/dist/internals/handler.js:105:13)
at async Object.apiResolver (/home/***/webapp/node_modules/next/dist/server/api-utils/node.js:182:9)
at async DevServer.runApi (/home/***/webapp/node_modules/next/dist/server/next-server.js:386:9)
at async Object.fn (/home/***/webapp/node_modules/next/dist/server/base-server.js:488:37)
at async Router.execute (/home/***/webapp/node_modules/next/dist/server/router.js:228:32) {
statusCode: 400,
errors: [ 'email must be an email' ]
}
What does the request body look like?
Request Body
{
"email": "leah@gmail.com"
}
I'm having the same issue if i change the DTO to
class NewsletterSubscribeRequestDto {
@IsString()
email: string;
}
And just enter a string, it then has the error message 'email bust be a string'
Hi @leahtopchik
I could reproduce the error you were having with next@12.1.0
(the version you're on) and can confirm that upgrading it to next@12.1.1
solved it for me. I don't know the underlying issue yet, but have to dig deeper for that.
Thanks that fixed that issue, now I have to figure out what broke from the upgrade. Cheers :)
I've read some other issues relating to this but nothing seems to work, I am getting a validation error on every request. The following is my code, package.json and tsconfig:
Any help would be greatly appreciated - I'm hoping it's something stupid on my end.