文件名称:next-api-middleware:Next.js API中间件
文件大小:13KB
文件格式:ZIP
更新时间:2024-03-04 21:09:18
react nodejs middleware nextjs koajs
Next.js API中间件 介绍 是将后端功能添加到React应用程序的一种非常有趣且简单的方法。 但是,当需要添加中间件时,没有简单的方法来实现它。 Next.js官方文档建议编写函数 :thumbs_down: 。 与Express.js或Koa.js提供的干净API相比,这是一大步。 该库尝试提供最小,干净,可组合的中间件模式,这些模式既富有成效又易于使用。 :party_popper: 快速开始 import { use } from "next-api-middleware" ; const middleware = use ( async ( req , res , next ) => { console . log ( "Do work before the request" ) ; await next ( ) ; console . log ( "Clean up" ) ; } ,
【文件预览】:
next-api-middleware-canary
----package.json(1KB)
----.github()
--------ISSUE_TEMPLATE()
--------workflows()
----LICENSE(1KB)
----jest.config.ts(6KB)
----tsconfig.json(428B)
----.gitignore(45B)
----lib()
--------index.spec.ts(6KB)
--------index.ts(3KB)
----CODE_OF_CONDUCT.md(3KB)
----README.md(6KB)
----babel.config.js(128B)