@guanghechen/middleware 1.0.0-alpha.7 → 1.0.2
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/CHANGELOG.md +22 -0
- package/lib/cjs/index.cjs +0 -8
- package/lib/esm/index.mjs +0 -2
- package/lib/types/index.d.ts +39 -4
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## <small>1.0.2 (2024-09-18)</small>
|
|
7
|
+
|
|
8
|
+
- :wrench: chore: upgrade devDependencies and fix configs
|
|
9
|
+
([230fb63](https://github.com/guanghechen/sora/commit/230fb63))
|
|
10
|
+
|
|
11
|
+
# Change Log
|
|
12
|
+
|
|
13
|
+
All notable changes to this project will be documented in this file. See
|
|
14
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
15
|
+
|
|
16
|
+
## [1.0.1](https://github.com/guanghechen/sora/compare/@guanghechen/middleware@1.0.0-alpha.7...@guanghechen/middleware@1.0.1) (2024-03-09)
|
|
17
|
+
|
|
18
|
+
### Performance Improvements
|
|
19
|
+
|
|
20
|
+
- :art: refactor middleware & remove middleware.types
|
|
21
|
+
([ba84d0c](https://github.com/guanghechen/sora/commit/ba84d0ca1d43a4778ab9551f7c8876d3b1c7fb94))
|
|
22
|
+
|
|
23
|
+
# Change Log
|
|
24
|
+
|
|
25
|
+
All notable changes to this project will be documented in this file. See
|
|
26
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
27
|
+
|
|
6
28
|
# [1.0.0-alpha.7](https://github.com/guanghechen/sora/compare/@guanghechen/middleware@1.0.0-alpha.6...@guanghechen/middleware@1.0.0-alpha.7) (2024-02-03)
|
|
7
29
|
|
|
8
30
|
### Performance Improvements
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var middleware_types = require('@guanghechen/middleware.types');
|
|
4
|
-
|
|
5
3
|
class AsyncMiddlewares {
|
|
6
4
|
_middlewares;
|
|
7
5
|
constructor() {
|
|
@@ -32,9 +30,3 @@ class Middlewares {
|
|
|
32
30
|
|
|
33
31
|
exports.AsyncMiddlewares = AsyncMiddlewares;
|
|
34
32
|
exports.Middlewares = Middlewares;
|
|
35
|
-
Object.keys(middleware_types).forEach(function (k) {
|
|
36
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () { return middleware_types[k]; }
|
|
39
|
-
});
|
|
40
|
-
});
|
package/lib/esm/index.mjs
CHANGED
package/lib/types/index.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
interface IAsyncMiddlewareNext<Output> {
|
|
2
|
+
(embryo: Readonly<Output | null>): Promise<Output | null>;
|
|
3
|
+
}
|
|
4
|
+
interface IAsyncMiddleware<Input, Output, Api> {
|
|
5
|
+
(input: Readonly<Input>, embryo: Readonly<Output> | null, api: Readonly<Api>, next: IAsyncMiddlewareNext<Output>): Promise<Output | null>;
|
|
6
|
+
}
|
|
7
|
+
interface IAsyncMiddlewares<Input, Output, Api> {
|
|
8
|
+
/**
|
|
9
|
+
* Use a middleware.
|
|
10
|
+
* @param middleware
|
|
11
|
+
*/
|
|
12
|
+
use(middleware: IAsyncMiddleware<Input, Output, Api>): void;
|
|
13
|
+
/**
|
|
14
|
+
* Run with the middlewares.
|
|
15
|
+
* @param input
|
|
16
|
+
* @param api
|
|
17
|
+
*/
|
|
18
|
+
reducer(input: Readonly<Input>, api: Readonly<Api>): IAsyncMiddlewareNext<Output>;
|
|
19
|
+
}
|
|
4
20
|
declare class AsyncMiddlewares<Input, Output, Api> implements IAsyncMiddlewares<Input, Output, Api> {
|
|
5
21
|
protected readonly _middlewares: Array<IAsyncMiddleware<Input, Output, Api>>;
|
|
6
22
|
constructor();
|
|
@@ -8,6 +24,25 @@ declare class AsyncMiddlewares<Input, Output, Api> implements IAsyncMiddlewares<
|
|
|
8
24
|
reducer(input: Readonly<Input>, api: Readonly<Api>): IAsyncMiddlewareNext<Output>;
|
|
9
25
|
}
|
|
10
26
|
|
|
27
|
+
interface IMiddlewareNext<Output> {
|
|
28
|
+
(embryo: Readonly<Output | null>): Output | null;
|
|
29
|
+
}
|
|
30
|
+
interface IMiddleware<Input, Output, Api> {
|
|
31
|
+
(input: Readonly<Input>, embryo: Readonly<Output> | null, api: Readonly<Api>, next: IMiddlewareNext<Output>): Output | null;
|
|
32
|
+
}
|
|
33
|
+
interface IMiddlewares<Input, Output, Api> {
|
|
34
|
+
/**
|
|
35
|
+
* Use a middleware.
|
|
36
|
+
* @param middleware
|
|
37
|
+
*/
|
|
38
|
+
use(middleware: IMiddleware<Input, Output, Api>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Run with the middlewares.
|
|
41
|
+
* @param input
|
|
42
|
+
* @param api
|
|
43
|
+
*/
|
|
44
|
+
reducer(input: Readonly<Input>, api: Readonly<Api>): IMiddlewareNext<Output>;
|
|
45
|
+
}
|
|
11
46
|
declare class Middlewares<Input, Output, Api> implements IMiddlewares<Input, Output, Api> {
|
|
12
47
|
protected readonly _middlewares: Array<IMiddleware<Input, Output, Api>>;
|
|
13
48
|
constructor();
|
|
@@ -15,4 +50,4 @@ declare class Middlewares<Input, Output, Api> implements IMiddlewares<Input, Out
|
|
|
15
50
|
reducer(input: Readonly<Input>, api: Readonly<Api>): IMiddlewareNext<Output>;
|
|
16
51
|
}
|
|
17
52
|
|
|
18
|
-
export { AsyncMiddlewares, Middlewares };
|
|
53
|
+
export { AsyncMiddlewares, type IAsyncMiddleware, type IAsyncMiddlewareNext, type IAsyncMiddlewares, type IMiddleware, type IMiddlewareNext, type IMiddlewares, Middlewares };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/middleware",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "types of @guanghechen/middleware",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guanghechen",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/middleware@1.0.
|
|
11
|
+
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/middleware@1.0.1",
|
|
12
12
|
"directory": "packages/middleware"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/middleware@1.0.
|
|
14
|
+
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/middleware@1.0.1/packages/middleware#readme",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -34,8 +34,5 @@
|
|
|
34
34
|
"LICENSE",
|
|
35
35
|
"README.md"
|
|
36
36
|
],
|
|
37
|
-
"
|
|
38
|
-
"@guanghechen/middleware.types": "^1.0.0-alpha.7"
|
|
39
|
-
},
|
|
40
|
-
"gitHead": "9c051a66df3f4dbd8eddd709046af0a975fdc702"
|
|
37
|
+
"gitHead": "61841206a2ca8060c0f47a32b9aa177b318f7c2e"
|
|
41
38
|
}
|