Open netgfx opened 4 months ago
I will take a look this week!
In the code above there are maybe two errors
ZodTypeProvider
for withTypeProvider
as generic.res.send
, as defined in schema
it should be a boolean but a string is being passed.Could you fix these points and verify if have the same problem?
Here is a fix suggestion:
fastify.withTypeProvider<ZodTypeProvider>().route({
method: 'POST',
url: '/login',
// Define your schema
schema: {
body: REGISTER_SCHEMA,
response: {
200: z.object({success: z.boolean()}),
},
},
handler: (req, res) => {
req.session.set('user', 'user-data');
res.send({success: true});
},
});
I have a weird issue were the
handler
function if set to return a json object like{success: "ok"}
it throws errorI implement it like this:
nothing special.
Isn't
res
the same as the fastifyreply
in terms of capabilities? The request header content-type is set to 'application/json'