Closed pct-cclausen closed 2 months ago
I've figured it out, carefully preparing examples typically leads to understanding problems and solving issue :)
The body needs to be an object or array or else body-parser gets unhappy due to this code in body-parser:
if (strict) {
var first = firstchar(body)
if (first !== '{' && first !== '[') {
debug('strict violation')
throw createStrictSyntaxError(body, first)
}
}
So either disable strict mode:
app.use(
bodyParser.json({
strict: false,
})
);
or make sure the body is an object, not just a string
Describe the bug
A contract that posts some data does not work, gets a server error. I am following this example: https://ts-rest.com/docs/quickstart#server-implementation
See this minimal example using express.
How to reproduce
Copy paste the example code into a workspace with ts-rest and run it via jest
Expected behavior
The test should pass, see the code
Code reproduction
ts-rest version
I am using ts-rest 3.44.1 and zod 3.22.4 with typescript 5.2.2 Also tried ts-rest 3.28.0 with typescript 5.0.2