I have an express app that is setup using routing-controllers. There is only one controller, and it looks like this:
@JsonController('/auth')
export class AuthController {
public authService = new AuthService();
@HttpCode(201)
@Post('/signup')
async signUp(@Body() data: SignUpDto) {
return await this.authService.signup(data);
}
}
And the SignUpDto
really doesn't have any validations on it:
export class SignUpDto {
userId: string;
email: string;
password: string;
}
However, when I send a request using cURL:
curl --cacert ./.cert/cert.pem -X POST https://localhost/auth/signup -H 'Content-ype: application/json' -d '{"userId":"01GKYW1JQBCJBXAK0VJTX92C6E","email":"01GKYSZ8AHSE@gmail.com","password":"A1@2e3r4"}'
I get 400 - Bad Request back:
{"name":"BadRequestError","message":"Invalid body, check 'errors' property for more info.","stack":"Error
at new HttpError (/home/user/Work/service/node_modules/routing-controllers/cjs/http-error/HttpError.js:17:22)
at new BadRequestError (/home/user/Work/service/node_modules/routing-controllers/cjs/http-error/BadRequestError.js:10:9)
at /home/user/Work/service/node_modules/routing-controllers/cjs/ActionParameterHandler.js:219:31
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ActionParameterHandler.normalizeParamValue (/home/user/Work/service/node_modules/routing-controllers/cjs/ActionParameterHandler.js:134:21)
at async Promise.all (index 0)","errors":[{"target":{"{\"userId\":\"01GKYW1JQBCJBXAK0VJTX92C6E\",\"email\":\"01GKYSZ8AHSE@gmail.com\",\"password\":\"A1@2e3r4\"}":""},"children":[],"constraints":{"unknownValue":"an unknown value was passed to the validate function"}}]}
I have been stuck on this for a few hours... any pointers on what could be causing this?