Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
nhttp/nhttpzod-validator for nhttp.
This package works with Cloudflare Workers, Node.js, Deno, BunIt is unknown whether this package works with Browsers
JSR Score
100%
Published
4 months ago (2.0.2)
Lib zod-validator
this libs for @nhttp/nhttp
Usage
import nhttp from "@nhttp/nhttp"; import validate, { z } from "@nhttp/zod"; const User = z.object({ username: z.string(), password: z.string(), user_info: z.object({ name: z.string(), address: z.string(), }), }); const app = nhttp(); // validate support all content-type (json, multipart, raw, urlencoded) app.post("/", validate(User), (rev) => { return rev.body.user_info; }); const userId = z.object({ userId: z.number(), }); // validate path params app.get("/users/:userId", validate(userId, "params"), (rev) => { return rev.params; }); const category = z.object({ category: z.string(), }); // validate query params app.get("/posts/:postId", validate(category, "query"), (rev) => { return rev.query; }); app.listen(8000, (_err, info) => { console.log(`Running on port ${info.port}`); });
Built and signed on
View transparency logGitHub Actions
Add Package
deno add jsr:@nhttp/zod
Import symbol
import * as mod from "@nhttp/zod";
---- OR ----
Import directly with a jsr specifier
import * as mod from "jsr:@nhttp/zod";
Add Package
npx jsr add @nhttp/zod
Import symbol
import * as mod from "@nhttp/zod";
Add Package
yarn dlx jsr add @nhttp/zod
Import symbol
import * as mod from "@nhttp/zod";
Add Package
pnpm dlx jsr add @nhttp/zod
Import symbol
import * as mod from "@nhttp/zod";
Add Package
bunx jsr add @nhttp/zod
Import symbol
import * as mod from "@nhttp/zod";