@asterflow/router 1.0.4 → 1.0.5

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 CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  # @asterflow/router
4
4
 
5
- ![license-info](https://img.shields.io/github/license/Ashu11-A/AsterFlow?style=for-the-badge&colorA=302D41&colorB=f9e2af&logoColor=f9e2af)
6
- ![stars-info](https://img.shields.io/github/stars/Ashu11-A/AsterFlow?colorA=302D41&colorB=f9e2af&style=for-the-badge)
5
+ ![license-info](https://img.shields.io/github/license/AsterFlow/AsterFlow?style=for-the-badge&colorA=302D41&colorB=f9e2af&logoColor=f9e2af)
6
+ ![stars-info](https://img.shields.io/github/stars/AsterFlow/AsterFlow?colorA=302D41&colorB=f9e2af&style=for-the-badge)
7
7
 
8
- ![last-commit](https://img.shields.io/github/last-commit/Ashu11-A/AsterFlow?style=for-the-badge&colorA=302D41&colorB=b4befe)
9
- ![commit-activity](https://img.shields.io/github/commit-activity/y/Ashu11-A/AsterFlow?style=for-the-badge&colorA=302D41&colorB=f9e2af)
10
- ![code-size](https://img.shields.io/github/languages/code-size/Ashu11-A/AsterFlow?style=for-the-badge&colorA=302D41&colorB=90dceb)
8
+ ![last-commit](https://img.shields.io/github/last-commit/AsterFlow/AsterFlow?style=for-the-badge&colorA=302D41&colorB=b4befe)
9
+ ![commit-activity](https://img.shields.io/github/commit-activity/y/AsterFlow/AsterFlow?style=for-the-badge&colorA=302D41&colorB=f9e2af)
10
+ ![code-size](https://img.shields.io/github/languages/code-size/AsterFlow/AsterFlow?style=for-the-badge&colorA=302D41&colorB=90dceb)
11
11
 
12
- ![top-language](https://img.shields.io/github/languages/top/Ashu11-A/AsterFlow?style=for-the-badge&colorA=302D41&colorB=90dceb)
12
+ ![top-language](https://img.shields.io/github/languages/top/AsterFlow/AsterFlow?style=for-the-badge&colorA=302D41&colorB=90dceb)
13
13
  ![bundle-size](https://img.shields.io/bundlejs/size/@asterflow/request?style=for-the-badge&colorA=302D41&colorB=3ac97b)
14
14
 
15
15
  </div>
@@ -162,7 +162,8 @@ app.listen(server, { port: 3333 }, (err) => {
162
162
  - [@asterflow/adapter](https://www.npmjs.com/package/@asterflow/adapter) - Adapters for different HTTP servers
163
163
  - [@asterflow/response](https://www.npmjs.com/package/@asterflow/response) - Type-safe HTTP response system
164
164
  - [@asterflow/request](https://www.npmjs.com/package/@asterflow/request) - Unified HTTP request system
165
+ - [@asterflow/plugin](https://www.npmjs.com/package/@asterflow/plugin) - A modular and typed plugin system
165
166
 
166
167
  ## 📄 License
167
168
 
168
- MIT - See [LICENSE](https://github.com/Ashu11-A/AsterFlow/blob/main/LICENSE) for more details.
169
+ MIT - See [LICENSE](https://github.com/AsterFlow/AsterFlow/blob/main/LICENSE) for more details.
@@ -1,32 +1,30 @@
1
1
  "use strict";
2
- var n = Object.defineProperty;
3
- var y = Object.getOwnPropertyDescriptor;
2
+ var a = Object.defineProperty;
3
+ var u = Object.getOwnPropertyDescriptor;
4
4
  var M = Object.getOwnPropertyNames;
5
- var u = Object.prototype.hasOwnProperty;
6
- var w = (t, e) => {
7
- for (var s in e)
8
- n(t, s, { get: e[s], enumerable: !0 });
9
- }, R = (t, e, s, d) => {
5
+ var w = Object.prototype.hasOwnProperty;
6
+ var R = (t, e) => {
7
+ for (var o in e)
8
+ a(t, o, { get: e[o], enumerable: !0 });
9
+ }, x = (t, e, o, d) => {
10
10
  if (e && typeof e == "object" || typeof e == "function")
11
- for (let r of M(e))
12
- !u.call(t, r) && r !== s && n(t, r, { get: () => e[r], enumerable: !(d = y(e, r)) || d.enumerable });
11
+ for (let s of M(e))
12
+ !w.call(t, s) && s !== o && a(t, s, { get: () => e[s], enumerable: !(d = u(e, s)) || d.enumerable });
13
13
  return t;
14
14
  };
15
- var x = (t) => R(n({}, "__esModule", { value: !0 }), t);
16
-
15
+ var f = (t) => x(a({}, "__esModule", { value: !0 }), t);
17
16
  // packages/router/src/index.ts
18
- var S = {};
19
- w(S, {
20
- Method: () => p,
21
- MethodType: () => h,
22
- Middleware: () => a,
23
- Router: () => o,
24
- createRouter: () => f
17
+ var g = {};
18
+ R(g, {
19
+ Method: () => m,
20
+ MethodType: () => l,
21
+ Middleware: () => p,
22
+ Router: () => n,
23
+ createRouter: () => S
25
24
  });
26
- module.exports = x(S);
27
-
25
+ module.exports = f(g);
28
26
  // packages/router/src/controllers/Router.ts
29
- var m = require("url-ast"), o = class {
27
+ var i = require("url-ast"), n = class {
30
28
  name;
31
29
  path;
32
30
  schema;
@@ -35,22 +33,20 @@ var m = require("url-ast"), o = class {
35
33
  use;
36
34
  url;
37
35
  constructor(e) {
38
- let { name: s, path: d, schema: r, description: l, methods: c } = e;
39
- this.name = s, this.path = d, this.schema = r, this.description = l, this.methods = c, this.use = e.use, this.url = new m.Analyze(this.path);
36
+ let { name: o, path: d, schema: s, description: c, methods: y } = e;
37
+ this.name = o, this.path = d, this.schema = s, this.description = c, this.methods = y, this.use = e.use, this.url = new i.Analyze(this.path);
40
38
  }
41
39
  };
42
-
43
40
  // packages/router/src/controllers/Middleware.ts
44
- var a = class {
41
+ var p = class {
45
42
  name;
46
43
  onRun;
47
44
  constructor(e) {
48
45
  this.name = e.name, this.onRun = e.onRun;
49
46
  }
50
47
  };
51
-
52
48
  // packages/router/src/controllers/Method.ts
53
- var i = require("url-ast"), p = class {
49
+ var h = require("url-ast"), m = class {
54
50
  path;
55
51
  url;
56
52
  method;
@@ -59,18 +55,15 @@ var i = require("url-ast"), p = class {
59
55
  use;
60
56
  handler;
61
57
  constructor(e) {
62
- this.path = e.path, this.url = new i.Analyze(this.path), this.method = e.method, this.schema = e.schema, this.handler = e.handler, this.use = e.use;
58
+ this.path = e.path, this.url = new h.Analyze(this.path), this.method = e.method, this.schema = e.schema, this.handler = e.handler, this.use = e.use;
63
59
  }
64
60
  };
65
-
66
61
  // packages/router/src/controllers/createRouter.ts
67
- function f() {
68
- return (t) => new o(t);
62
+ function S() {
63
+ return (t) => new n(t);
69
64
  }
70
-
71
65
  // packages/router/src/types/method.ts
72
- var h = /* @__PURE__ */ ((r) => (r.get = "get", r.post = "post", r.put = "put", r.delete = "delete", r))(h || {});
73
- // Annotate the CommonJS export names for ESM import in node:
66
+ var l = ((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))(l || {});
74
67
  0 && (module.exports = {
75
68
  Method,
76
69
  MethodType,
package/dist/mjs/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // packages/router/src/controllers/Router.ts
2
- import { Analyze as i } from "url-ast";
2
+ import { Analyze as h } from "url-ast";
3
3
  var s = class {
4
4
  name;
5
5
  path;
@@ -9,11 +9,10 @@ var s = class {
9
9
  use;
10
10
  url;
11
11
  constructor(e) {
12
- let { name: n, path: a, schema: t, description: p, methods: m } = e;
13
- this.name = n, this.path = a, this.schema = t, this.description = p, this.methods = m, this.use = e.use, this.url = new i(this.path);
12
+ let { name: d, path: a, schema: p, description: m, methods: i } = e;
13
+ this.name = d, this.path = a, this.schema = p, this.description = m, this.methods = i, this.use = e.use, this.url = new h(this.path);
14
14
  }
15
15
  };
16
-
17
16
  // packages/router/src/controllers/Middleware.ts
18
17
  var o = class {
19
18
  name;
@@ -22,10 +21,9 @@ var o = class {
22
21
  this.name = e.name, this.onRun = e.onRun;
23
22
  }
24
23
  };
25
-
26
24
  // packages/router/src/controllers/Method.ts
27
- import { Analyze as h } from "url-ast";
28
- var d = class {
25
+ import { Analyze as l } from "url-ast";
26
+ var n = class {
29
27
  path;
30
28
  url;
31
29
  method;
@@ -34,21 +32,19 @@ var d = class {
34
32
  use;
35
33
  handler;
36
34
  constructor(e) {
37
- this.path = e.path, this.url = new h(this.path), this.method = e.method, this.schema = e.schema, this.handler = e.handler, this.use = e.use;
35
+ this.path = e.path, this.url = new l(this.path), this.method = e.method, this.schema = e.schema, this.handler = e.handler, this.use = e.use;
38
36
  }
39
37
  };
40
-
41
38
  // packages/router/src/controllers/createRouter.ts
42
- function x() {
39
+ function f() {
43
40
  return (r) => new s(r);
44
41
  }
45
-
46
42
  // packages/router/src/types/method.ts
47
- var l = /* @__PURE__ */ ((t) => (t.get = "get", t.post = "post", t.put = "put", t.delete = "delete", t))(l || {});
43
+ var c = ((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))(c || {});
48
44
  export {
49
- d as Method,
50
- l as MethodType,
45
+ n as Method,
46
+ c as MethodType,
51
47
  o as Middleware,
52
48
  s as Router,
53
- x as createRouter
49
+ f as createRouter
54
50
  };
@@ -5,15 +5,17 @@ import type { Middleware } from '../controllers/Middleware';
5
5
  import type { AnyMiddleware, MiddlewareOutput } from './mindleware';
6
6
  import type { AnySchema, InferSchema } from './schema';
7
7
  export declare enum MethodType {
8
+ all = "all",
8
9
  get = "get",
9
10
  post = "post",
10
11
  put = "put",
11
- delete = "delete"
12
+ delete = "delete",
13
+ options = "options",
14
+ head = "head",
15
+ patch = "patch"
12
16
  }
17
+ export type AnyMethodHandler = MethodHandler<string, Responders, AnySchema, AnyMiddleware[], MiddlewareOutput<AnyMiddleware[]>>;
13
18
  export type MethodKeys = keyof typeof MethodType;
14
- export type AnyMethodHandler = {
15
- [Method in MethodKeys]?: MethodHandler<string, Responders, AnySchema, AnyMiddleware[], MiddlewareOutput<AnyMiddleware[]>>;
16
- };
17
19
  export type MethodHandler<Path extends string, Responder extends Responders, Schema extends AnySchema, Middlewares extends readonly Middleware<Responder, Schema, string, Record<string, unknown>>[], Context extends MiddlewareOutput<Middlewares>> = <RequestType>(args: {
18
20
  request: Request<RequestType>;
19
21
  response: Response<Responder>;
@@ -10,7 +10,7 @@ import type { AnySchema, InferredData, SchemaDynamic } from './schema';
10
10
  export type AnyRouteHandler = {
11
11
  [Method in MethodKeys]?: RouteHandler<string, Responders, Method, SchemaDynamic<Method>, AnyMiddleware[], MiddlewareOutput<AnyMiddleware[]>>;
12
12
  };
13
- export type AnyRouter = Router<Responders, string, SchemaDynamic<MethodKeys>, AnyMiddleware[], MiddlewareOutput<AnyMiddleware[]>, AnyRouteHandler> | Method<Responders, string, MethodKeys, AnySchema, AnyMiddleware[], MiddlewareOutput<AnyMiddleware[]>, any>;
13
+ export type AnyRouter = Router<any, any, any, any, any, any> | Method<any, any, any, any, any, any, any>;
14
14
  export type RouteHandler<Path extends string, Responder extends Responders, Method extends MethodKeys, Schema extends SchemaDynamic<Method>, Middlewares extends readonly Middleware<Responder, AnySchema, string, Record<string, unknown>>[], Context extends MiddlewareOutput<Middlewares>> = <RequestType>(args: {
15
15
  request: Request<RequestType>;
16
16
  response: Response<Responder>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asterflow/router",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "main": "dist/cjs/index.cjs",
5
5
  "module": "dist/mjs/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -18,10 +18,9 @@
18
18
  "node": ">=20"
19
19
  },
20
20
  "devDependencies": {
21
- "@asterflow/request": "1.0.4",
22
- "@asterflow/response": "1.0.1",
21
+ "@asterflow/request": "1.0.5",
22
+ "@asterflow/response": "1.0.2",
23
23
  "@caeljs/tsh": "^1.1.3",
24
- "@types/bun": "latest",
25
24
  "fastify": "^5.3.3",
26
25
  "zod": "^3.25.62"
27
26
  },