@creator.co/wapi 1.5.9-alpha.5 → 1.5.9-alpha.6

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.5.9-alpha.4",
3
+ "version": "1.5.9-alpha.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { Route, RouterConfig } from './Router';
1
+ import { AnyRoute, RouterConfig } from './Router';
2
2
  import { HttpMethod } from '../API/Request';
3
3
  /**
4
4
  * A class that resolves routes based on the provided configuration.
@@ -24,7 +24,7 @@ export default class RouteResolver {
24
24
  * @param {string} path - The path of the request.
25
25
  * @returns {Route | undefined} - The resolved route or undefined if no route is found.
26
26
  */
27
- resolveRoute(method: HttpMethod, path: string): Route | undefined;
27
+ resolveRoute(method: HttpMethod, path: string): AnyRoute | undefined;
28
28
  /**
29
29
  * Builds the routes for the router based on the given configuration.
30
30
  * @param {RouterConfig} config - The router configuration object.
@@ -1 +1 @@
1
- {"version":3,"file":"RouteResolver.js","sourceRoot":"","sources":["../../../src/Server/RouteResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAGA;;GAEG;AACH;IAkBE;;;OAGG;IACH;QACE,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;IAChB,CAAC;IAED;;;;;;OAMG;IACI,yBAAQ,GAAf,UAAgB,KAAY,EAAE,KAAe;QAC3C,IAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC3B,IAAI,KAAK,EAAE;YACT,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,MAAM,EAAE,CAAA;gBAC7C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAA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C,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,EAAR,CAAQ,CAAC,CAAA;QACnD,OAAO,MAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,0CAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACK,mCAAW,GAAnB,UAAoB,MAAoB;;;YACtC,KAAoB,IAAA,KAAA,SAAA,MAAM,CAAC,MAAM,CAAA,gBAAA,4BAAE;gBAA9B,IAAM,KAAK,WAAA;gBACd,IAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,EAAR,CAAQ,CAAC,CAAA;gBACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,EAAE,CAAA;gBACrE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;aAClD;;;;;;;;;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAzCD,IAyCC"}
@@ -56,6 +56,7 @@ export interface Route<InputType = never, OutputType = never, PathParamsType = S
56
56
  */
57
57
  querySchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>;
58
58
  }
59
+ export type AnyRoute = Route<any, any>;
59
60
  /**
60
61
  * Represents the configuration options for a router.
61
62
  * @typedef {TransactionConfig & {
@@ -78,7 +79,7 @@ export type RouterConfig = TransactionConfig & {
78
79
  * An array of route objects representing the available routes in the application.
79
80
  * @type {Route[]}
80
81
  */
81
- routes: Route[];
82
+ routes: AnyRoute[];
82
83
  /**
83
84
  * The port number for the server to listen on.
84
85
  * @type {number | undefined}
@@ -1 +1 @@
1
- {"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;AAQjC,uCAAiC;AA0HjC;;GAEG;AACH;IAUE;;;;OAIG;IACH,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,yBAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,CAAA;IACrF,CAAC;IAED;;;OAGG;IACI,0BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;IAChC,CAAC;IAED;;;OAGG;IACK,4BAAW,GAAnB;QACE,OAAO,eAAK,CAAC,qBAAqB,EAAE,CAAA;IACtC,CAAC;IACH,aAAC;AAAD,CAAC,AAnCD,IAmCC"}
1
+ {"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;AAQjC,uCAAiC;AA4HjC;;GAEG;AACH;IAUE;;;;OAIG;IACH,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,yBAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,CAAA;IACrF,CAAC;IAED;;;OAGG;IACI,0BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;IAChC,CAAC;IAED;;;OAGG;IACK,4BAAW,GAAnB;QACE,OAAO,eAAK,CAAC,qBAAqB,EAAE,CAAA;IACtC,CAAC;IACH,aAAC;AAAD,CAAC,AAnCD,IAmCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.5.9-alpha.5",
3
+ "version": "1.5.9-alpha.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { Route, RouterConfig } from './Router'
1
+ import { AnyRoute, RouterConfig } from './Router'
2
2
  import { HttpMethod } from '../API/Request'
3
3
 
4
4
  /**
@@ -9,7 +9,7 @@ class Routes {
9
9
  * Represents the current route.
10
10
  * @type {Route | undefined}
11
11
  */
12
- private current?: Route
12
+ private current?: AnyRoute
13
13
  /**
14
14
  * Optional private variable that represents a collection of routes.
15
15
  * @type {Routes | undefined}
@@ -37,7 +37,7 @@ class Routes {
37
37
  * @returns None
38
38
  * @throws {Error} If a duplicate route is detected.
39
39
  */
40
- public addRoute(route: Route, parts: string[]): void {
40
+ public addRoute(route: AnyRoute, parts: string[]): void {
41
41
  const first = parts.shift()
42
42
  if (first) {
43
43
  if (first.startsWith(':')) {
@@ -59,7 +59,7 @@ class Routes {
59
59
  * @param {string[]} parts - An array of route parts.
60
60
  * @returns {Route} The resolved route.
61
61
  */
62
- public resolveRoute(parts: string[]): Route<never, never> | undefined {
62
+ public resolveRoute(parts: string[]): AnyRoute | undefined {
63
63
  const first = parts.shift()
64
64
  if (first) {
65
65
  if (first in this.next) {
@@ -99,7 +99,7 @@ export default class RouteResolver {
99
99
  * @param {string} path - The path of the request.
100
100
  * @returns {Route | undefined} - The resolved route or undefined if no route is found.
101
101
  */
102
- public resolveRoute(method: HttpMethod, path: string): Route | undefined {
102
+ public resolveRoute(method: HttpMethod, path: string): AnyRoute | undefined {
103
103
  const parts = path.split('/').filter(p => p.length)
104
104
  return this.routes[method]?.resolveRoute(parts)
105
105
  }
@@ -82,6 +82,8 @@ export interface Route<
82
82
  querySchema?: z.ZodObject<any> | z.ZodUnion<any> | z.ZodIntersection<any, any>
83
83
  }
84
84
 
85
+ export type AnyRoute = Route<any, any>
86
+
85
87
  /**
86
88
  * Represents the configuration options for a router.
87
89
  * @typedef {TransactionConfig & {
@@ -104,7 +106,7 @@ export type RouterConfig = TransactionConfig & {
104
106
  * An array of route objects representing the available routes in the application.
105
107
  * @type {Route[]}
106
108
  */
107
- routes: Route[]
109
+ routes: AnyRoute[]
108
110
  /**
109
111
  * The port number for the server to listen on.
110
112
  * @type {number | undefined}