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