routefly 1.0.3 → 1.0.4

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
@@ -60,6 +60,11 @@ declare class RouteflyApp {
60
60
  mountRoutes(): void;
61
61
  start(port: number): Promise<void>;
62
62
  getAdapter(): ServerPort;
63
+ get(path: string, ...handlers: Function[]): this;
64
+ post(path: string, ...handlers: Function[]): this;
65
+ put(path: string, ...handlers: Function[]): this;
66
+ patch(path: string, ...handlers: Function[]): this;
67
+ delete(path: string, ...handlers: Function[]): this;
63
68
  }
64
69
  declare const app: RouteflyApp;
65
70
  declare function bootstrap(config?: ConfigServer, createConfigFile?: boolean): Promise<RouteflyApp>;
package/dist/index.js CHANGED
@@ -464,6 +464,19 @@ var Patch = createRouteDecorator("PATCH");
464
464
  var Delete = createRouteDecorator("DELETE");
465
465
 
466
466
  // src/bootstrap.ts
467
+ function registerRoute(method, path, handlersAndMiddlewares) {
468
+ const middlewares = handlersAndMiddlewares.slice(0, -1);
469
+ const handler = handlersAndMiddlewares.at(-1);
470
+ if (!handler) {
471
+ throw new Error(`Handler obrigatorio para ${method} ${path}`);
472
+ }
473
+ RouteRegistry.add({
474
+ method,
475
+ path,
476
+ handler,
477
+ middlewares
478
+ });
479
+ }
467
480
  var RouteflyApp = class {
468
481
  adapter;
469
482
  mounted = false;
@@ -502,6 +515,26 @@ var RouteflyApp = class {
502
515
  getAdapter() {
503
516
  return this.adapter;
504
517
  }
518
+ get(path, ...handlers) {
519
+ registerRoute("GET", path, handlers);
520
+ return this;
521
+ }
522
+ post(path, ...handlers) {
523
+ registerRoute("POST", path, handlers);
524
+ return this;
525
+ }
526
+ put(path, ...handlers) {
527
+ registerRoute("PUT", path, handlers);
528
+ return this;
529
+ }
530
+ patch(path, ...handlers) {
531
+ registerRoute("PATCH", path, handlers);
532
+ return this;
533
+ }
534
+ delete(path, ...handlers) {
535
+ registerRoute("DELETE", path, handlers);
536
+ return this;
537
+ }
505
538
  };
506
539
  var app = new RouteflyApp(new HonoServerAdapter());
507
540
  async function bootstrap(config2, createConfigFile = false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routefly",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Framework web com decorator",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",