0.14.1 • Published 3 months ago

@spectrajs/arktype v0.14.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@spectrajs/arktype

codecov GitHub Workflow Status License npm npm Bundle Size

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.

0.14.1

3 months ago

0.14.0

3 months ago