@asterflow/router 1.0.8 → 1.0.9
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 +2 -2
- package/dist/cjs/index.cjs +20 -22
- package/dist/mjs/index.js +7 -11
- package/dist/types/controllers/Method.d.ts +1 -3
- package/dist/types/controllers/Router.d.ts +0 -2
- package/dist/types/types/method.d.ts +1 -1
- package/dist/types/types/mindleware.d.ts +1 -0
- package/dist/types/types/router.d.ts +1 -1
- package/package.json +4 -7
package/README.md
CHANGED
|
@@ -131,7 +131,7 @@ const router = new Router({
|
|
|
131
131
|
|
|
132
132
|
```typescript
|
|
133
133
|
import { adapters } from '@asterflow/adapter'
|
|
134
|
-
import { AsterFlow } from '
|
|
134
|
+
import { AsterFlow } from 'asterflow'
|
|
135
135
|
import fastify from 'fastify'
|
|
136
136
|
|
|
137
137
|
const server = fastify()
|
|
@@ -154,7 +154,7 @@ app.listen(server, { port: 3333 }, (err) => {
|
|
|
154
154
|
|
|
155
155
|
## 🔗 Related Packages
|
|
156
156
|
|
|
157
|
-
- [
|
|
157
|
+
- [asterflow](https://www.npmjs.com/package/asterflow) - Core framework
|
|
158
158
|
- [@asterflow/adapter](https://www.npmjs.com/package/@asterflow/adapter) - Adapters for different HTTP servers
|
|
159
159
|
- [@asterflow/response](https://www.npmjs.com/package/@asterflow/response) - Type-safe HTTP response system
|
|
160
160
|
- [@asterflow/request](https://www.npmjs.com/package/@asterflow/request) - Unified HTTP request system
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
2
|
+
var o = Object.defineProperty;
|
|
3
|
+
var c = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var w = Object.getOwnPropertyNames;
|
|
5
|
+
var y = Object.prototype.hasOwnProperty;
|
|
6
|
+
var M = (t, e) => {
|
|
7
7
|
for (var n in e)
|
|
8
|
-
|
|
9
|
-
},
|
|
8
|
+
o(t, n, { get: e[n], enumerable: !0 });
|
|
9
|
+
}, u = (t, e, n, d) => {
|
|
10
10
|
if (e && typeof e == "object" || typeof e == "function")
|
|
11
|
-
for (let s of
|
|
12
|
-
!
|
|
11
|
+
for (let s of w(e))
|
|
12
|
+
!y.call(t, s) && s !== n && o(t, s, { get: () => e[s], enumerable: !(d = c(e, s)) || d.enumerable });
|
|
13
13
|
return t;
|
|
14
14
|
};
|
|
15
|
-
var
|
|
15
|
+
var x = (t) => u(o({}, "__esModule", { value: !0 }), t);
|
|
16
16
|
// packages/router/src/index.ts
|
|
17
|
-
var
|
|
18
|
-
|
|
17
|
+
var R = {};
|
|
18
|
+
M(R, {
|
|
19
19
|
Method: () => p,
|
|
20
|
-
MethodType: () =>
|
|
20
|
+
MethodType: () => m,
|
|
21
21
|
Middleware: () => i,
|
|
22
22
|
Router: () => a
|
|
23
23
|
});
|
|
24
|
-
module.exports =
|
|
24
|
+
module.exports = x(R);
|
|
25
25
|
// packages/router/src/controllers/Router.ts
|
|
26
|
-
var
|
|
26
|
+
var a = class t {
|
|
27
27
|
name;
|
|
28
28
|
path;
|
|
29
29
|
schema;
|
|
30
30
|
description;
|
|
31
31
|
methods;
|
|
32
32
|
use;
|
|
33
|
-
url;
|
|
34
33
|
constructor(e) {
|
|
35
|
-
let { name: n, path:
|
|
36
|
-
this.name = n, this.path =
|
|
34
|
+
let { name: n, path: d, schema: s, description: h, methods: l } = e;
|
|
35
|
+
this.name = n, this.path = d, this.schema = s, this.description = h, this.methods = l, this.use = e.use;
|
|
37
36
|
}
|
|
38
37
|
static create() {
|
|
39
38
|
return (e) => new t(e);
|
|
@@ -48,20 +47,19 @@ var i = class {
|
|
|
48
47
|
}
|
|
49
48
|
};
|
|
50
49
|
// packages/router/src/controllers/Method.ts
|
|
51
|
-
var
|
|
50
|
+
var p = class {
|
|
52
51
|
path;
|
|
53
|
-
url;
|
|
54
52
|
method;
|
|
55
53
|
schema;
|
|
56
54
|
name;
|
|
57
55
|
use;
|
|
58
56
|
handler;
|
|
59
57
|
constructor(e) {
|
|
60
|
-
this.path = e.path, this.
|
|
58
|
+
this.path = e.path, this.method = e.method, this.schema = e.schema, this.handler = e.handler, this.use = e.use;
|
|
61
59
|
}
|
|
62
60
|
};
|
|
63
61
|
// packages/router/src/types/method.ts
|
|
64
|
-
var
|
|
62
|
+
var m = ((r) => (r.all = "all", r.get = "get", r.post = "post", r.put = "put", r.delete = "delete", r.options = "options", r.head = "head", r.patch = "patch", r))(m || {});
|
|
65
63
|
0 && (module.exports = {
|
|
66
64
|
Method,
|
|
67
65
|
MethodType,
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// packages/router/src/controllers/Router.ts
|
|
2
|
-
import { Analyze as h } from "@asterflow/url-parser";
|
|
3
2
|
var s = class r {
|
|
4
3
|
name;
|
|
5
4
|
path;
|
|
@@ -7,10 +6,9 @@ var s = class r {
|
|
|
7
6
|
description;
|
|
8
7
|
methods;
|
|
9
8
|
use;
|
|
10
|
-
url;
|
|
11
9
|
constructor(e) {
|
|
12
|
-
let { name:
|
|
13
|
-
this.name =
|
|
10
|
+
let { name: o, path: a, schema: i, description: p, methods: m } = e;
|
|
11
|
+
this.name = o, this.path = a, this.schema = i, this.description = p, this.methods = m, this.use = e.use;
|
|
14
12
|
}
|
|
15
13
|
static create() {
|
|
16
14
|
return (e) => new r(e);
|
|
@@ -25,24 +23,22 @@ var n = class {
|
|
|
25
23
|
}
|
|
26
24
|
};
|
|
27
25
|
// packages/router/src/controllers/Method.ts
|
|
28
|
-
|
|
29
|
-
var o = class {
|
|
26
|
+
var d = class {
|
|
30
27
|
path;
|
|
31
|
-
url;
|
|
32
28
|
method;
|
|
33
29
|
schema;
|
|
34
30
|
name;
|
|
35
31
|
use;
|
|
36
32
|
handler;
|
|
37
33
|
constructor(e) {
|
|
38
|
-
this.path = e.path, this.
|
|
34
|
+
this.path = e.path, this.method = e.method, this.schema = e.schema, this.handler = e.handler, this.use = e.use;
|
|
39
35
|
}
|
|
40
36
|
};
|
|
41
37
|
// packages/router/src/types/method.ts
|
|
42
|
-
var
|
|
38
|
+
var h = ((t) => (t.all = "all", t.get = "get", t.post = "post", t.put = "put", t.delete = "delete", t.options = "options", t.head = "head", t.patch = "patch", t))(h || {});
|
|
43
39
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
d as Method,
|
|
41
|
+
h as MethodType,
|
|
46
42
|
n as Middleware,
|
|
47
43
|
s as Router
|
|
48
44
|
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { Runtime } from '@asterflow/adapter';
|
|
2
|
-
import type { AnyAsterflow } from '
|
|
2
|
+
import type { AnyAsterflow } from 'asterflow';
|
|
3
3
|
import type { Responders } from '@asterflow/response';
|
|
4
|
-
import { Analyze } from '@asterflow/url-parser';
|
|
5
4
|
import type { MethodHandler, MethodKeys, MethodOptions } from '../types/method';
|
|
6
5
|
import type { MiddlewareOutput } from '../types/mindleware';
|
|
7
6
|
import type { AnySchema } from '../types/schema';
|
|
8
7
|
import type { Middleware } from './Middleware';
|
|
9
8
|
export declare class Method<Responder extends Responders, const Path extends string = string, const Drive extends Runtime = Runtime, const Method extends MethodKeys = MethodKeys, const Schema extends AnySchema = AnySchema, const Middlewares extends readonly Middleware<Responder, Schema, string, Record<string, unknown>>[] = [], const Context extends MiddlewareOutput<Middlewares> = MiddlewareOutput<Middlewares>, const Instance extends AnyAsterflow = AnyAsterflow, const Handler extends MethodHandler<Path, Drive, Responder, Schema, Middlewares, Context, Instance> = MethodHandler<Path, Drive, Responder, Schema, Middlewares, Context, Instance>> {
|
|
10
9
|
path: Path;
|
|
11
|
-
url: Analyze<Path>;
|
|
12
10
|
method: Method;
|
|
13
11
|
schema?: Schema;
|
|
14
12
|
name?: string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Responders } from '@asterflow/response';
|
|
2
|
-
import { Analyze } from '@asterflow/url-parser';
|
|
3
2
|
import type { MethodKeys } from '../types/method';
|
|
4
3
|
import type { MiddlewareOutput } from '../types/mindleware';
|
|
5
4
|
import type { RouteHandler, RouterOptions } from '../types/router';
|
|
@@ -16,7 +15,6 @@ export declare class Router<Responder extends Responders, const Path extends str
|
|
|
16
15
|
description?: string;
|
|
17
16
|
methods: Routers;
|
|
18
17
|
use?: Middlewares;
|
|
19
|
-
url: Analyze<Path>;
|
|
20
18
|
constructor(options: RouterOptions<Path, Schema, Responder, Middlewares, Context, Routers>);
|
|
21
19
|
static create<Responder extends Responders>(): <const Path extends string, const Schema extends SchemaDynamic<MethodKeys>, const Middlewares extends readonly Middleware<Responder, AnySchema, string, Record<string, unknown>>[], const Context extends MiddlewareOutput<Middlewares>, const Routers extends { [Method in MethodKeys]?: RouteHandler<Path, Responder, Method, Schema, Middlewares, Context>; }>(options: RouterOptions<Path, Schema, Responder, Middlewares, Context, Routers>) => Router<Responder, Path, Schema, Middlewares, Context, Routers>;
|
|
22
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Runtime } from '@asterflow/adapter';
|
|
2
|
-
import type { AnyAsterflow } from '
|
|
2
|
+
import type { AnyAsterflow } from 'asterflow';
|
|
3
3
|
import type { AsterRequest } from '@asterflow/request';
|
|
4
4
|
import type { Responders, AsterResponse } from '@asterflow/response';
|
|
5
5
|
import type { Analyze, ParsePath } from '@asterflow/url-parser';
|
|
@@ -4,6 +4,7 @@ import type { Responders, AsterResponse } from '@asterflow/response';
|
|
|
4
4
|
import type { Middleware } from '../controllers/Middleware';
|
|
5
5
|
import type { AnySchema, InferSchema } from './schema';
|
|
6
6
|
export type AnyMiddleware = Middleware<any, any, any, any>;
|
|
7
|
+
export type AnyMiddlewares = readonly AnyMiddleware[];
|
|
7
8
|
/**
|
|
8
9
|
* Accumulate the output types (`P`) from an array of middlewares into a single object
|
|
9
10
|
*/
|
|
@@ -18,7 +18,7 @@ export type RouteHandler<Path extends string, Responder extends Responders, Meth
|
|
|
18
18
|
url: Analyze<Path, ParsePath<Path>, Analyze<Path>>;
|
|
19
19
|
schema: InferredData<Method, Schema>;
|
|
20
20
|
middleware: Context;
|
|
21
|
-
}) => Promise<
|
|
21
|
+
}) => Promise<AsterResponse> | AsterResponse;
|
|
22
22
|
export type RouterOptions<Path extends string, Schema extends SchemaDynamic<MethodKeys>, Responder extends Responders, Middlewares extends readonly Middleware<Responder, AnySchema, string, Record<string, unknown>>[], Context extends MiddlewareOutput<Middlewares>, Routers extends {
|
|
23
23
|
[Method in MethodKeys]?: RouteHandler<Path, Responder, Method, Schema, Middlewares, Context>;
|
|
24
24
|
}> = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asterflow/router",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"main": "dist/cjs/index.cjs",
|
|
5
5
|
"module": "dist/mjs/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -18,16 +18,13 @@
|
|
|
18
18
|
"node": ">=20"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@asterflow/request": "1.0.
|
|
22
|
-
"@asterflow/response": "1.0.
|
|
23
|
-
"
|
|
21
|
+
"@asterflow/request": "1.0.9",
|
|
22
|
+
"@asterflow/response": "1.0.6",
|
|
23
|
+
"asterflow": "0.0.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@caeljs/tsh": "^1.1.3",
|
|
27
27
|
"zod": "^3.25.63",
|
|
28
28
|
"typescript": "^5.8.3"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@asterflow/url-parser": "^2.0.1"
|
|
32
29
|
}
|
|
33
30
|
}
|