use-next-middleware:Next.js API路由的中间件

时间:2021-04-04 11:39:12
【文件属性】:
文件名称:use-next-middleware:Next.js API路由的中间件
文件大小:5KB
文件格式:ZIP
更新时间:2021-04-04 11:39:12
react middleware nextjs next api-routes Next.js API路由的中间件 Next.js发布了版本9,该版本添加了API路由。 这使我们能够编写API。 当前,Next.js发行了版本10,但是,我认为...仍然缺少一些东西:中间件。 因为正式的Next.js文档建议在编写函数,所以没有简单的方法来实现它。 所以,我写了use-next-middleware 。 这是非常干净,最少且可组合的中间件模式。 安装 使用软件包管理器yarn或npm安装use-next-middleware 。 yarn install use-next-middleware 快速开始 import { useNextMiddleware } from 'next-api-middleware' import { NextApiRequest } from 'next' const handler = async ( req , res ) =>
【文件预览】:
use-next-middleware-master
----.gitignore(39B)
----tsconfig.json(1KB)
----README.md(2KB)
----test()
--------index.test.ts(74B)
----LICENSE(1KB)
----package.json(2KB)
----src()
--------index.ts(770B)

网友评论