0.2.2 • Published 2 years ago

next-handler v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Features

  • 🔒 Full type safety on body, query & response
  • ✅ Zod type validation out of the box
  • ✉️ Send json response via return
  • 👮 Error and notFound handlers
  • 🍃 Zero dependencies

Installation

npm install next-handler
# or
yarn add next-handler

Basic Usage

import { nh } from 'next-handler';

const handler = nh().post(
  {
    query: z.object({
      id: z.string().transform((id) => parseInt(id)),
    }),
    body: z.object({
      data: z.string(),
    }),
  },
  ({ req }) => {
    // full type safety provided on query and body
    data.set(req.query.id, req.body.data);

    // send json response via return
    return { ok: true };
  }
);

export default handler.build();
0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago