0.14.1 • Published 3 months ago
@spectrajs/zod v0.14.1
@spectrajs/zod
A validator middleware using Zod for Spectra.
Installation
npm install @spectrajs/zod
Documentation
The documentation is available here.
Usage
import { Spectra } from "@spectrajs/core";
import { z } from "zod";
import { zodValidator } from "@spectrajs/zod";
const app = new Spectra();
const schema = z.object({
name: z.string(),
age: z.number(),
});
app.post("/post", zodValidator("json", schema), async (c) => {
const { name, age } = c.req.valid<z.infer<typeof schema>>("json");
return c.json({ name, age });
});
export default app;
License
Distributed under the MIT License. See LICENSE for more information.