@kanjijs/platform-hono 0.2.0-beta.1 → 0.2.0-beta.10

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.
Files changed (2) hide show
  1. package/dist/index.js +64 -57
  2. package/package.json +6 -4
package/dist/index.js CHANGED
@@ -2843,69 +2843,73 @@ var methodMetadataStore = new WeakMap;
2843
2843
  var controllerMetadataStore = new WeakMap;
2844
2844
  var moduleMetadataStore = new WeakMap;
2845
2845
  var injectionMetadataStore = new WeakMap;
2846
- var MetadataStorage = {
2847
- addRoute(target, methodName, meta) {
2848
- let methods = methodMetadataStore.get(target);
2849
- if (!methods) {
2850
- methods = new Map;
2851
- methodMetadataStore.set(target, methods);
2852
- }
2853
- const existing = methods.get(methodName) || {};
2854
- methods.set(methodName, { ...existing, ...meta });
2855
- },
2856
- addContract(target, methodName, contract) {
2857
- let methods = methodMetadataStore.get(target);
2858
- if (!methods) {
2859
- methods = new Map;
2860
- methodMetadataStore.set(target, methods);
2861
- }
2862
- const existing = methods.get(methodName) || {};
2863
- existing.contract = contract;
2864
- methods.set(methodName, existing);
2865
- },
2866
- addMiddleware(target, middleware, methodName) {
2867
- if (methodName) {
2846
+ var globalStore = globalThis;
2847
+ if (!globalStore.KANJI_METADATA_STORAGE) {
2848
+ globalStore.KANJI_METADATA_STORAGE = {
2849
+ addRoute(target, methodName, meta) {
2868
2850
  let methods = methodMetadataStore.get(target);
2869
2851
  if (!methods) {
2870
2852
  methods = new Map;
2871
2853
  methodMetadataStore.set(target, methods);
2872
2854
  }
2873
2855
  const existing = methods.get(methodName) || {};
2874
- existing.middlewares = [...existing.middlewares || [], middleware];
2856
+ methods.set(methodName, { ...existing, ...meta });
2857
+ },
2858
+ addContract(target, methodName, contract) {
2859
+ let methods = methodMetadataStore.get(target);
2860
+ if (!methods) {
2861
+ methods = new Map;
2862
+ methodMetadataStore.set(target, methods);
2863
+ }
2864
+ const existing = methods.get(methodName) || {};
2865
+ existing.contract = contract;
2875
2866
  methods.set(methodName, existing);
2876
- } else {
2877
- const existing = controllerMetadataStore.get(target) || { prefix: "/" };
2878
- existing.middlewares = [...existing.middlewares || [], middleware];
2879
- controllerMetadataStore.set(target, existing);
2880
- }
2881
- },
2882
- getRoutes(target) {
2883
- return methodMetadataStore.get(target);
2884
- },
2885
- setController(target, meta) {
2886
- controllerMetadataStore.set(target, meta);
2887
- },
2888
- getController(target) {
2889
- return controllerMetadataStore.get(target);
2890
- },
2891
- defineModule(target, meta) {
2892
- moduleMetadataStore.set(target, meta);
2893
- },
2894
- getModule(target) {
2895
- return moduleMetadataStore.get(target);
2896
- },
2897
- addInjection(target, index, token) {
2898
- let injections = injectionMetadataStore.get(target);
2899
- if (!injections) {
2900
- injections = new Map;
2901
- injectionMetadataStore.set(target, injections);
2902
- }
2903
- injections.set(index, token);
2904
- },
2905
- getInjections(target) {
2906
- return injectionMetadataStore.get(target);
2907
- }
2908
- };
2867
+ },
2868
+ addMiddleware(target, middleware, methodName) {
2869
+ if (methodName) {
2870
+ let methods = methodMetadataStore.get(target);
2871
+ if (!methods) {
2872
+ methods = new Map;
2873
+ methodMetadataStore.set(target, methods);
2874
+ }
2875
+ const existing = methods.get(methodName) || {};
2876
+ existing.middlewares = [...existing.middlewares || [], middleware];
2877
+ methods.set(methodName, existing);
2878
+ } else {
2879
+ const existing = controllerMetadataStore.get(target) || { prefix: "/" };
2880
+ existing.middlewares = [...existing.middlewares || [], middleware];
2881
+ controllerMetadataStore.set(target, existing);
2882
+ }
2883
+ },
2884
+ getRoutes(target) {
2885
+ return methodMetadataStore.get(target);
2886
+ },
2887
+ setController(target, meta) {
2888
+ controllerMetadataStore.set(target, meta);
2889
+ },
2890
+ getController(target) {
2891
+ return controllerMetadataStore.get(target);
2892
+ },
2893
+ defineModule(target, meta) {
2894
+ moduleMetadataStore.set(target, meta);
2895
+ },
2896
+ getModule(target) {
2897
+ return moduleMetadataStore.get(target);
2898
+ },
2899
+ addInjection(target, index, token) {
2900
+ let injections = injectionMetadataStore.get(target);
2901
+ if (!injections) {
2902
+ injections = new Map;
2903
+ injectionMetadataStore.set(target, injections);
2904
+ }
2905
+ injections.set(index, token);
2906
+ },
2907
+ getInjections(target) {
2908
+ return injectionMetadataStore.get(target);
2909
+ }
2910
+ };
2911
+ }
2912
+ var MetadataStorage = globalStore.KANJI_METADATA_STORAGE;
2909
2913
  function createMethodDecorator(method) {
2910
2914
  return (path = "/") => {
2911
2915
  return (target, propertyKey) => {
@@ -3290,8 +3294,11 @@ class KanjijsAdapter {
3290
3294
  return [];
3291
3295
  visited.add(moduleClass);
3292
3296
  const meta = MetadataStorage.getModule(moduleClass);
3293
- if (!meta)
3297
+ if (!meta) {
3298
+ console.error(`[Kanjijs] No metadata found for module: ${moduleClass.name}. Did you forget @Module()?`);
3294
3299
  return [];
3300
+ }
3301
+ console.log(`[Kanjijs] Found module metadata for: ${moduleClass.name}. Controllers: ${meta.controllers?.length}`);
3295
3302
  const controllers = [...meta.controllers || []];
3296
3303
  const imports = [...meta.imports || [], ...target.imports || []];
3297
3304
  for (const imp of imports) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanjijs/platform-hono",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -13,10 +13,12 @@
13
13
  "build": "bun build src/index.ts --outdir dist --target bun"
14
14
  },
15
15
  "dependencies": {
16
- "@kanjijs/common": "workspace:*",
17
- "@kanjijs/core": "workspace:*",
18
- "@kanjijs/contracts": "workspace:*",
16
+ "@kanjijs/common": "^0.2.0-beta.10",
17
+ "@kanjijs/contracts": "^0.2.0-beta.10",
19
18
  "hono": "^4.0.0",
20
19
  "reflect-metadata": "^0.2.0"
20
+ },
21
+ "peerDependencies": {
22
+ "@kanjijs/core": "^0.2.0-beta.10"
21
23
  }
22
24
  }