0.0.1 • Published 9 months ago

@kzb/express-zod-endpoint v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

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