nextjs-api-handler

1.0.7 • Public • Published

NextJS API Handler

The most EZ way to handle your Next JS API's requests !

Install

Install with npm:

$ npm i --save nextjs-api-handler

Usage

Import :

import { requestHandler } from "nextjs-api-handler";

export default async (req: NextApiRequest, res: NextApiResponse) => requestHandler(req, res, {
    GET: () => getHandler(req,res),
    POST: () => postHandler(req, res),
    // 
})
const getHandler = (req: NextApiRequest, res: NextApiResponse) => res.status(200).send("OK");
const postHandler = async (req: NextApiRequest, res: NextApiResponse) => {
    // handle your route
}

// TODO : usage of errorHandler

/nextjs-api-handler/

    Package Sidebar

    Install

    npm i nextjs-api-handler

    Weekly Downloads

    2

    Version

    1.0.7

    License

    MIC

    Unpacked Size

    3.92 kB

    Total Files

    6

    Last publish

    Collaborators

    • matryxxx02