Skip to content

Commit 51da414

Browse files
committed
nmc-20 add more information to readme
1 parent 963cbb6 commit 51da414

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
# @nimpl/middleware-chain
22

3-
The package allows you to create a chain of native next.js middlewares without any modifications (*i.e., you can add any ready-made middleware to the chain*)
3+
The package allows you to create a chain of native next.js middlewares without any modifications (_i.e., you can add any ready-made middleware to the chain_)
44

55
```ts
66
// middleware.ts
77
import { chain } from "@nimpl/middleware-chain";
88

99
export default chain([
10-
intlMiddleware,
11-
authMiddleware,
12-
customMiddleware,
10+
[intlMiddleware, { exclude: /^\/private(\/.*)?$/ }],
11+
authMiddleware,
12+
(req, event) => {
13+
event.waitUntil(
14+
fetch("https://my-analytics-platform.com", {
15+
method: "POST",
16+
body: JSON.stringify({ pathname: req.nextUrl.pathname }),
17+
})
18+
);
19+
return NextResponse.next();
20+
},
21+
customMiddleware,
1322
]);
1423
```
1524

@@ -18,7 +27,6 @@ Visit https://nimpl.tech/middleware-chain to view the full documentation.
1827
## Installation
1928

2029
**Using npm:**
21-
n the format of its API.
2230

2331
```bash
2432
npm i @nimpl/middleware-chain
@@ -30,16 +38,30 @@ npm i @nimpl/middleware-chain
3038
yarn add @nimpl/middleware-chain
3139
```
3240

41+
## Motivation
42+
43+
All existing solutions work through their own APIs - made under the style of express or in their own vision. They are useful, well implemented, and convenient. But only in cases where you can update every used middleware.
44+
45+
However, there are many situations where you need to add already prepared solutions. Usually, in the issues of these solutions, you can find “support to add a chain package A, working with chain package B”.
46+
47+
This package follows a plug and play format. In the best traditions of the previous next.js.
48+
49+
This is not Koa and not Express, this is a package for next.js, in its unique style, in the format of its API.
50+
3351
## Examples
3452

35-
* [Base example](https://github.com/vordgi/nimpl-middleware-chain/tree/main/examples/base).
36-
* [next-auth + next-intl example](https://github.com/vordgi/nimpl-middleware-chain/tree/main/examples/auth-intl).
53+
- [Base example](https://github.com/vordgi/nimpl-middleware-chain/tree/main/examples/base).
54+
- [next-auth + next-intl example](https://github.com/vordgi/nimpl-middleware-chain/tree/main/examples/auth-intl).
55+
56+
## Development
57+
58+
Read about working on the package and making changes on the contribution page
3759

3860
## Additional
3961

40-
Please consider giving a star if you like it, it shows that the package is useful and helps continue work on this and other packages.
62+
Please consider giving a star if you like it, it shows that the package is useful and helps me continue work on this and other packages.
4163

42-
Create issues for identified issues, desired getters, or various improvements.
64+
Create issues with wishes, ideas, difficulties, etc. All of them will definitely be considered and thought over.
4365

4466
## License
4567

0 commit comments

Comments
 (0)