@objectstack/hono 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # @objectstack/hono
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @objectstack/runtime@1.0.1
9
+
10
+ ## 1.0.0
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+ - @objectstack/runtime@1.0.0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,KAAK,YAAY,EAAwC,MAAM,sBAAsB,CAAC;AAE/F,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,sBAAsB,8EAsK5D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,IAC1C,GAAG,GAAG,EAAE,MAAM,GAAG,mBAIhC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,KAAK,YAAY,EAAwC,MAAM,sBAAsB,CAAC;AAE/F,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,sBAAsB,8EAmL5D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,IAC1C,GAAG,GAAG,EAAE,MAAM,GAAG,mBAIhC"}
package/dist/index.js CHANGED
@@ -68,7 +68,19 @@ function createHonoApp(options) {
68
68
  app.all(`${prefix}/metadata*`, async (c) => {
69
69
  try {
70
70
  const path = c.req.path.substring(c.req.path.indexOf('/metadata') + 9);
71
- const result = await dispatcher.handleMetadata(path, { request: c.req.raw });
71
+ const method = c.req.method;
72
+ let body = undefined;
73
+ if (method === 'PUT' || method === 'POST') {
74
+ // Attempt to parse JSON body
75
+ try {
76
+ body = await c.req.json();
77
+ }
78
+ catch (e) {
79
+ // Ignore parse errors, body remains undefined or empty
80
+ body = {};
81
+ }
82
+ }
83
+ const result = await dispatcher.handleMetadata(path, { request: c.req.raw }, method, body);
72
84
  return normalizeResponse(c, result);
73
85
  }
74
86
  catch (err) {
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@objectstack/hono",
3
- "version": "0.1.0",
3
+ "version": "1.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "peerDependencies": {
8
8
  "hono": "^4.0.0",
9
- "@objectstack/runtime": "0.9.2"
9
+ "@objectstack/runtime": "1.0.1"
10
10
  },
11
11
  "devDependencies": {
12
12
  "hono": "^4.0.0",
13
13
  "typescript": "^5.0.0",
14
- "@objectstack/runtime": "0.9.2"
14
+ "@objectstack/runtime": "1.0.1"
15
15
  },
16
16
  "scripts": {
17
17
  "build": "tsc"
package/src/index.ts CHANGED
@@ -76,7 +76,20 @@ export function createHonoApp(options: ObjectStackHonoOptions) {
76
76
  app.all(`${prefix}/metadata*`, async (c) => {
77
77
  try {
78
78
  const path = c.req.path.substring(c.req.path.indexOf('/metadata') + 9);
79
- const result = await dispatcher.handleMetadata(path, { request: c.req.raw });
79
+ const method = c.req.method;
80
+ let body = undefined;
81
+
82
+ if (method === 'PUT' || method === 'POST') {
83
+ // Attempt to parse JSON body
84
+ try {
85
+ body = await c.req.json();
86
+ } catch (e) {
87
+ // Ignore parse errors, body remains undefined or empty
88
+ body = {};
89
+ }
90
+ }
91
+
92
+ const result = await dispatcher.handleMetadata(path, { request: c.req.raw }, method, body);
80
93
  return normalizeResponse(c, result);
81
94
  } catch (err: any) {
82
95
  return c.json({ success: false, error: { message: err.message, code: err.statusCode || 500 } }, err.statusCode || 500);