@wxn0brp/falcon-frame 0.4.0 → 0.4.1

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/index.d.ts CHANGED
@@ -29,11 +29,11 @@ export declare class FalconFrame<Vars extends Record<string, any> = any> extends
29
29
  * Sets the allowed origins for CORS.
30
30
  * This method is a shortcut that simplifies CORS configuration
31
31
  * without needing to manually create and register a plugin.
32
- * @param origin - An array of allowed origins.
32
+ * @param [origin] - An array of allowed origins. (default: ["*"])
33
33
  * @example
34
34
  * app.setOrigin(["http://example.com", "https://example.com"]);
35
35
  */
36
- setOrigin(origin: string[]): void;
36
+ setOrigin(origin?: string[] | string): void;
37
37
  }
38
38
  export default FalconFrame;
39
39
  export * as Helpers from "./helpers.js";
package/dist/index.js CHANGED
@@ -84,12 +84,12 @@ export class FalconFrame extends Router {
84
84
  * Sets the allowed origins for CORS.
85
85
  * This method is a shortcut that simplifies CORS configuration
86
86
  * without needing to manually create and register a plugin.
87
- * @param origin - An array of allowed origins.
87
+ * @param [origin] - An array of allowed origins. (default: ["*"])
88
88
  * @example
89
89
  * app.setOrigin(["http://example.com", "https://example.com"]);
90
90
  */
91
- setOrigin(origin) {
92
- this.use(createCORSPlugin(origin).process);
91
+ setOrigin(origin = "*") {
92
+ this.use(createCORSPlugin(Array.isArray(origin) ? origin : [origin]).process);
93
93
  }
94
94
  }
95
95
  export default FalconFrame;
package/dist/router.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PluginSystem } from "./plugin.js";
2
- import { Method, Middleware, RouteHandler, StaticServeOptions } from "./types.js";
3
2
  import { SSEManager } from "./sse.js";
3
+ import { Method, Middleware, RouteHandler, StaticServeOptions } from "./types.js";
4
4
  export type MiddlewareFn = RouteHandler | Router | PluginSystem;
5
5
  export declare class Router {
6
6
  middlewares: Middleware[];
@@ -14,4 +14,5 @@ export declare class Router {
14
14
  static(apiPath: string, dirPath?: string, opts?: StaticServeOptions): this;
15
15
  sse(path: string, ...handlers: RouteHandler[]): SSEManager;
16
16
  customParser(path: string, handler: RouteHandler, method?: Method): this;
17
+ router(path: string): Router;
17
18
  }
package/dist/router.js CHANGED
@@ -71,4 +71,9 @@ export class Router {
71
71
  this.middlewares[index - 1].customParser = true;
72
72
  return this;
73
73
  }
74
+ router(path) {
75
+ const router = new Router();
76
+ this.use(path, router);
77
+ return router;
78
+ }
74
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/falcon-frame",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",
@@ -34,4 +34,4 @@
34
34
  "import": "./dist/*.js"
35
35
  }
36
36
  }
37
- }
37
+ }