Skip to content

Commit c05cd60

Browse files
Merge pull request #1 from typescript-package/develop
v0.0.1
2 parents c986c11 + 1a56bbb commit c05cd60

14 files changed

+511
-0
lines changed

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: [angular-package] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: angularpackage # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: [
13+
'https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29',
14+
'https://donate.stripe.com/dR614hfDZcJE3wAcMM'
15+
] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db
43+
44+
*.ignore*
45+
temp

README.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
2+
<a href="https://www.typescriptlang.org/">
3+
<img
4+
src="https://raw.githubusercontent.com/typescript-package/core/refs/heads/main/ts-package-barcode-logo-512.png"
5+
width="20%"
6+
title="@typescript-package/middleware - A lightweight TypeScript library for middleware."
7+
/>
8+
</a>
9+
10+
## @typescript-package/middleware
11+
12+
<!-- npm badge -->
13+
[![npm version][typescript-package-npm-badge-svg]][typescript-package-npm-badge]
14+
[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues]
15+
[![GitHub license][typescript-package-badge-license]][typescript-package-license]
16+
17+
A **lightweight** TypeScript library for middleware.
18+
19+
## Features
20+
21+
## Table of contents
22+
23+
- [Installation](#installation)
24+
- [Api](#api)
25+
- Class
26+
- [`Middleware`](#middleware)
27+
- [Contributing](#contributing)
28+
- [Support](#support)
29+
- [Code of Conduct](code-of-conduct)
30+
- [Git](#git)
31+
- [Commit](#commit)
32+
- [Versioning](#versioning)
33+
- [License](#license)
34+
- [Related packages](#related-packages)
35+
36+
## Installation
37+
38+
### 1. Install the package
39+
40+
```bash
41+
npm install @typescript-package/middleware --save-peer
42+
```
43+
44+
## Api
45+
46+
### `Middleware`
47+
48+
```typescript
49+
import { Middleware } from '@typescript-package/middleware';
50+
51+
// Initialize.
52+
const middleware = new Middleware();
53+
54+
// Add middleware.
55+
middleware.use((args, next) => {
56+
console.log('Middleware 1 executed with args:', args);
57+
58+
// Modify args.
59+
args[0].newKey = 'newValue';
60+
61+
// Execute next.
62+
next();
63+
});
64+
65+
middleware.use((args, next) => {
66+
console.log('Middleware 2 executed with args:', args);
67+
68+
// Execute next.
69+
next();
70+
});
71+
72+
// logs
73+
// Middleware 1 executed with args: [ { key: 'value' } ]
74+
// Middleware 2 executed with args: [ { key: 'value', newKey: 'newValue' } ]
75+
middleware.execute({ key: 'value' });
76+
77+
78+
// Async
79+
middleware.use(async (args, next) => {
80+
console.log('Async middleware 1 start with args:', args);
81+
args[0].newKey = 'newValue';
82+
await new Promise(resolve => setTimeout(resolve, 2000));
83+
console.log('Async middleware end');
84+
next();
85+
});
86+
87+
middleware.use(async (args, next) => {
88+
console.log('Async middleware 2 start with args:', args);
89+
next();
90+
});
91+
92+
middleware.onComplete((args) => {
93+
console.log('All middlewares completed with args:', args);
94+
});
95+
96+
middleware.executeAsync({ key: 'value' });
97+
```
98+
99+
## Contributing
100+
101+
Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.
102+
103+
## Support
104+
105+
If you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.
106+
107+
Support via:
108+
109+
- [Stripe](https://donate.stripe.com/dR614hfDZcJE3wAcMM)
110+
- [Revolut](https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29)
111+
- [GitHub](https://github.com/sponsors/angular-package/sponsorships?sponsor=sciborrudnicki&tier_id=83618)
112+
- [DonorBox](https://donorbox.org/become-a-sponsor-to-the-angular-package?default_interval=o)
113+
- [Patreon](https://www.patreon.com/checkout/angularpackage?rid=0&fan_landing=true&view_as=public)
114+
115+
or via Trust Wallet
116+
117+
- [XLM](https://link.trustwallet.com/send?coin=148&address=GAFFFB7H3LG42O6JA63FJDRK4PP4JCNEOPHLGLLFH625X2KFYQ4UYVM4)
118+
- [USDT (BEP20)](https://link.trustwallet.com/send?coin=20000714&address=0xA0c22A2bc7E37C1d5992dFDFFeD5E6f9298E1b94&token_id=0x55d398326f99059fF775485246999027B3197955)
119+
- [ETH](https://link.trustwallet.com/send?coin=60&address=0xA0c22A2bc7E37C1d5992dFDFFeD5E6f9298E1b94)
120+
- [BTC](https://link.trustwallet.com/send?coin=0&address=bc1qnf709336tfl57ta5mfkf4t9fndhx7agxvv9svn)
121+
- [BNB](https://link.trustwallet.com/send?coin=20000714&address=0xA0c22A2bc7E37C1d5992dFDFFeD5E6f9298E1b94)
122+
123+
## Code of Conduct
124+
125+
By participating in this project, you agree to follow **[Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/)**.
126+
127+
## GIT
128+
129+
### Commit
130+
131+
Please follow the following commit message conventions:
132+
133+
- [AngularJS Git Commit Message Conventions][git-commit-angular]
134+
- [Karma Git Commit Msg][git-commit-karma]
135+
- [Conventional Commits][git-commit-conventional]
136+
137+
### Versioning
138+
139+
The package follows [Semantic Versioning 2.0.0][git-semver] for all releases. The versioning format is:
140+
141+
**Given a version number MAJOR.MINOR.PATCH, increment the:**
142+
143+
- MAJOR version when you make incompatible API changes,
144+
- MINOR version when you add functionality in a backwards-compatible manner, and
145+
- PATCH version when you make backwards-compatible bug fixes.
146+
147+
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
148+
149+
**FAQ**
150+
How should I deal with revisions in the 0.y.z initial development phase?
151+
152+
> The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.
153+
154+
How do I know when to release 1.0.0?
155+
156+
> If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.
157+
158+
## License
159+
160+
MIT © typescript-package ([license][typescript-package-license])
161+
162+
## Related packages
163+
164+
- **[@typescript-package/chain-descriptor](https://github.com/typescript-package/chain-descriptor)**: A **TypeScript** library for chain property descriptor.
165+
- **[@typescript-package/controller](https://github.com/typescript-package/controller)**: A **TypeScript** package with for various kind of controllers.
166+
- **[@typescript-package/descriptor](https://github.com/typescript-package/descriptor)**: A **TypeScript** library for property descriptor.
167+
- **[@typescript-package/descriptor-chain](https://github.com/typescript-package/descriptor-chain)**: A **TypeScript** library for property descriptor chain.
168+
- **[@typescript-package/descriptors](https://github.com/typescript-package/descriptors)**: A **TypeScript** library for property descriptors.
169+
- **[@typescript-package/property](https://github.com/typescript-package/property)**: A **TypeScript** package with features to handle object properties.
170+
- **[@typescript-package/wrap-descriptor](https://github.com/typescript-package/wrap-descriptor)**: A **TypeScript** package for wrapping object descriptors.
171+
- **[@typescript-package/wrap-property](https://github.com/typescript-package/wrap-property)**: A **TypeScript** package for wrapping object properties.
172+
- **[@typescript-package/wrapped-descriptor](https://github.com/typescript-package/wrapped-descriptor)**: A **TypeScript** library for wrapped property descriptor.
173+
- **[@xtypescript/property](https://github.com/xtypescript/property)** - A comprehensive, reactive **TypeScript** library for precise and extensible object property control.
174+
175+
<!-- This package: typescript-package -->
176+
<!-- GitHub: badges -->
177+
[typescript-package-badge-issues]: https://img.shields.io/github/issues/typescript-package/middleware
178+
[isscript-package-badge-forks]: https://img.shields.io/github/forks/typescript-package/middleware
179+
[typescript-package-badge-stars]: https://img.shields.io/github/stars/typescript-package/middleware
180+
[typescript-package-badge-license]: https://img.shields.io/github/license/typescript-package/middleware
181+
<!-- GitHub: badges links -->
182+
[typescript-package-issues]: https://github.com/typescript-package/middleware/issues
183+
[typescript-package-forks]: https://github.com/typescript-package/middleware/network
184+
[typescript-package-license]: https://github.com/typescript-package/middleware/blob/master/LICENSE
185+
[typescript-package-stars]: https://github.com/typescript-package/middleware/stargazers
186+
<!-- This package -->
187+
188+
<!-- Package: typescript-package -->
189+
<!-- npm -->
190+
[typescript-package-npm-badge-svg]: https://badge.fury.io/js/@typescript-package%2Fmiddleware.svg
191+
[typescript-package-npm-badge]: https://badge.fury.io/js/@typescript-package%2Fmiddleware
192+
193+
<!-- GIT -->
194+
[git-semver]: http://semver.org/
195+
196+
<!-- GIT: commit -->
197+
[git-commit-angular]: https://gist.github.com/stephenparish/9941e89d80e2bc58a153
198+
[git-commit-karma]: http://karma-runner.github.io/0.10/dev/git-commit-msg.html
199+
[git-commit-conventional]: https://www.conventionalcommits.org/en/v1.0.0/

ng-package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../dist/middleware",
4+
"lib": {
5+
"entryFile": "src/public-api.ts"
6+
},
7+
"keepLifecycleScripts": true
8+
}

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@typescript-package/middleware",
3+
"version": "0.0.1",
4+
"author": "wwwdev.io <dev@wwwdev.io>",
5+
"description": "A lightweight TypeScript library for middleware.",
6+
"license": "MIT",
7+
"publishConfig": {
8+
"access": "public",
9+
"registry": "https://registry.npmjs.org"
10+
},
11+
"devDependencies": {},
12+
"peerDependencies": {},
13+
"scripts": {
14+
"prepublishOnly": "npm run pkg && npm run clean",
15+
"pkg": "npm pkg delete dependencies",
16+
"clean": "npm pkg delete scripts"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/typescript-package/middleware.git"
21+
},
22+
"bugs": {
23+
"url": "https://github.com/typescript-package/middleware/issues"
24+
},
25+
"keywords": [
26+
"@typescript-package",
27+
"@typescript-package/middleware"
28+
],
29+
"funding": [
30+
{
31+
"type": "individual",
32+
"url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29"
33+
}
34+
],
35+
"sideEffects": false
36+
}

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Middleware } from './middleware.class';

0 commit comments

Comments
 (0)