0.0.1 • Published 3 years ago

@ootiq/next-api-router v0.0.1

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

next-api-router

Custom route handler for Nextjs's file-sytem api routing.

Install

# pnpm
pnpm add @ootiq/next-api-router

# yarn
yarn add @ootiq/next-api-router

# npm
npm install @ootiq/next-api-router

Usage

// pages/api/hello.ts
import Router from "@ootiq/next-api-router";

const router = new Router();

export default router
  .post((req, res) => {
    res.send("Hello world");
  })
  .get((req, res) => {
    res.send("get request");
  })
  .all((req, res) => {
    res.status(404).send("not found");
  })
  .handle();

© 2022 | TheBoringDude