0.0.1 • Published 9 months ago
@kzb/express-zod-endpoint v0.0.1
express-zod-endpoint
Validation middleware for ExpressJs based on zod.
Usage
import { z } from 'zod';
router.post('/my/endpoint', authorization, endpoint({
body: z.object({
one: z.number().positive(),
two: z.string().trim(),
}),
query: z.object({
three: z.string().trim(),
}),
}, async ({ body, query, res }) => {
const { one, two } = body;
console.log(one, two, query.three);
return res.send({ result: 42 });
}));
0.0.1
9 months ago