@philiprehberger/middleware-ts 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# @philiprehberger/ts
|
|
1
|
+
# @philiprehberger/middleware-ts
|
|
2
2
|
|
|
3
|
-
[](https://github.com/philiprehberger/middleware-ts/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@philiprehberger/middleware-ts)
|
|
5
|
+
[](https://github.com/philiprehberger/middleware-ts/commits/main)
|
|
6
6
|
|
|
7
|
-
Framework-agnostic middleware composition engine
|
|
7
|
+
Framework-agnostic middleware composition engine
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install @philiprehberger/ts
|
|
12
|
+
npm install @philiprehberger/middleware-ts
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
import { compose, createPipeline } from '@philiprehberger/ts
|
|
18
|
+
import { compose, createPipeline } from '@philiprehberger/middleware-ts';
|
|
19
19
|
|
|
20
20
|
type Ctx = { req: Request; user?: User };
|
|
21
21
|
|
|
@@ -31,7 +31,7 @@ await app({ req: new Request('/api') });
|
|
|
31
31
|
### Conditional Branching
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
|
-
import { branch } from '@philiprehberger/ts
|
|
34
|
+
import { branch } from '@philiprehberger/middleware-ts';
|
|
35
35
|
|
|
36
36
|
const authBranch = branch(
|
|
37
37
|
(ctx) => ctx.req.url.startsWith('/api'),
|
|
@@ -49,7 +49,6 @@ const authBranch = branch(
|
|
|
49
49
|
| `branch(condition, trueMw, falseMw?)` | Conditional middleware |
|
|
50
50
|
| `withErrorHandler(mw, handler)` | Wrap with error catching |
|
|
51
51
|
|
|
52
|
-
|
|
53
52
|
## Development
|
|
54
53
|
|
|
55
54
|
```bash
|
|
@@ -58,6 +57,24 @@ npm run build
|
|
|
58
57
|
npm test
|
|
59
58
|
```
|
|
60
59
|
|
|
60
|
+
## Support
|
|
61
|
+
|
|
62
|
+
If you find this project useful:
|
|
63
|
+
|
|
64
|
+
⭐ [Star the repo](https://github.com/philiprehberger/middleware-ts)
|
|
65
|
+
|
|
66
|
+
🐛 [Report issues](https://github.com/philiprehberger/middleware-ts/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
|
|
67
|
+
|
|
68
|
+
💡 [Suggest features](https://github.com/philiprehberger/middleware-ts/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
|
|
69
|
+
|
|
70
|
+
❤️ [Sponsor development](https://github.com/sponsors/philiprehberger)
|
|
71
|
+
|
|
72
|
+
🌐 [All Open Source Projects](https://philiprehberger.com/open-source-packages)
|
|
73
|
+
|
|
74
|
+
💻 [GitHub Profile](https://github.com/philiprehberger)
|
|
75
|
+
|
|
76
|
+
🔗 [LinkedIn Profile](https://www.linkedin.com/in/philiprehberger)
|
|
77
|
+
|
|
61
78
|
## License
|
|
62
79
|
|
|
63
|
-
MIT
|
|
80
|
+
[MIT](LICENSE)
|