routefly 1.0.0 → 1.0.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
@@ -38,11 +38,11 @@ declare class RouteRegistry {
38
38
  static clear(): void;
39
39
  }
40
40
 
41
- declare const Get: (path: string, ...middlewares: Function[]) => (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
42
- declare const Post: (path: string, ...middlewares: Function[]) => (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
43
- declare const Put: (path: string, ...middlewares: Function[]) => (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
44
- declare const Patch: (path: string, ...middlewares: Function[]) => (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
45
- declare const Delete: (path: string, ...middlewares: Function[]) => (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
41
+ declare const Get: (path: string, ...middlewares: Function[]) => (target: any, propertyKeyOrContext: any, descriptor?: PropertyDescriptor) => any;
42
+ declare const Post: (path: string, ...middlewares: Function[]) => (target: any, propertyKeyOrContext: any, descriptor?: PropertyDescriptor) => any;
43
+ declare const Put: (path: string, ...middlewares: Function[]) => (target: any, propertyKeyOrContext: any, descriptor?: PropertyDescriptor) => any;
44
+ declare const Patch: (path: string, ...middlewares: Function[]) => (target: any, propertyKeyOrContext: any, descriptor?: PropertyDescriptor) => any;
45
+ declare const Delete: (path: string, ...middlewares: Function[]) => (target: any, propertyKeyOrContext: any, descriptor?: PropertyDescriptor) => any;
46
46
 
47
47
  declare class HonoServerAdapter implements ServerPort {
48
48
  private app;
package/dist/index.js CHANGED
@@ -19,19 +19,38 @@ var RouteRegistry = class {
19
19
  // src/core/decorators.ts
20
20
  function createRouteDecorator(method) {
21
21
  return function(path, ...middlewares) {
22
- return function(target, propertyKey, descriptor) {
23
- const originalMethod = descriptor.value;
24
- const handler = async function(req, res) {
25
- const instance = new target.constructor();
26
- return originalMethod.call(instance, req, res);
27
- };
28
- RouteRegistry.add({
29
- method: method.toUpperCase(),
30
- path,
31
- handler,
32
- middlewares
33
- });
34
- return descriptor;
22
+ return function(target, propertyKeyOrContext, descriptor) {
23
+ const isTC39 = descriptor === void 0 && propertyKeyOrContext && typeof propertyKeyOrContext === "object" && "kind" in propertyKeyOrContext;
24
+ if (isTC39) {
25
+ const context = propertyKeyOrContext;
26
+ const methodName = context.name;
27
+ const originalMethod = target[methodName];
28
+ const handler = async function(req, res) {
29
+ const instance = new target.constructor();
30
+ return originalMethod.call(instance, req, res);
31
+ };
32
+ RouteRegistry.add({
33
+ method: method.toUpperCase(),
34
+ path,
35
+ handler,
36
+ middlewares
37
+ });
38
+ return originalMethod;
39
+ } else {
40
+ const propertyKey = propertyKeyOrContext;
41
+ const originalMethod = descriptor.value;
42
+ const handler = async function(req, res) {
43
+ const instance = new target.constructor();
44
+ return originalMethod.call(instance, req, res);
45
+ };
46
+ RouteRegistry.add({
47
+ method: method.toUpperCase(),
48
+ path,
49
+ handler,
50
+ middlewares
51
+ });
52
+ return descriptor;
53
+ }
35
54
  };
36
55
  };
37
56
  }
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "routefly",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Framework web com decorator",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
9
- "build": "tsup",
10
- "dev": "tsup --watch",
11
- "prepublishOnly": "npm run build"
9
+ "build": "tsup",
10
+ "dev": "tsup --watch",
11
+ "prepublishOnly": "npm run build"
12
12
  },
13
13
  "dependencies": {
14
14
  "@hono/node-server": "^2.1.11",
15
- "hono": "^4.0.0"
15
+ "hono": "^4.0.0",
16
+ "routefly": "^1.0.0"
16
17
  },
17
18
  "devDependencies": {
18
19
  "@types/bun": "^1.4.5",