UNPKG

nextjs-api-router

Version:

Lightweight tool to build clean restful API routes for your Next.js application.

22 lines (19 loc) 457 B
import { NextApiRequest, NextApiResponse } from "next"; export type Method = | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH"; export type Handler<T = any> = ( req: NextApiRequest, res: NextApiResponse<T>, next: (value?: unknown) => void ) => unknown; export type Controller<T = any> = | Record<Method, Handler<T> | Handler<T>[] | undefined> | Record<string, Handler<T> | Handler<T>[]>;