@lshay/next-router
v0.5.4
Published
Adds basic routing to Next.js API routes. Also allows for wrapping handler functions to mutate the context that is being passed in.
Downloads
6
Readme
@lshay/next-router
Adds basic routing to Next.js API routes. Also allows for wrapping handler functions to mutate the context that is being passed in.
Example
pages/api/hello.js
:
import { router } from "@lshay/next-router";
const wrapper = (req, res, handler) => handler({ req, res, wrapped: true });
const get = (ctx) => ctx.res.json({ message: "Hello, World!" });
export default middleware(wrapper).get(get).handler();