@ahmedbaset/adminjs-hono 0.1.2 → 0.1.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.
@@ -43,23 +43,22 @@ export function routeHandler(admin, route) {
43
43
  ...files,
44
44
  };
45
45
  // Execute the controller action
46
- const html = await controller[route.action]({
46
+ const result = await controller[route.action]({
47
47
  ...c.req,
48
48
  params,
49
49
  query,
50
50
  payload,
51
51
  method,
52
52
  }, c.res);
53
- // Set Content-Type header if specified
54
53
  if (route.contentType) {
55
- c.header('Content-Type', route.contentType);
54
+ c.header("Content-Type", route.contentType);
56
55
  }
57
- // Return response
58
- if (html) {
59
- return c.body(html);
56
+ // Return JSON or HTML based on route
57
+ if (route.contentType === "application/json" ||
58
+ route.path.startsWith("/api")) {
59
+ return c.json(result);
60
60
  }
61
- // If no response body, return empty response
62
- return c.body(null);
61
+ return c.html(result);
63
62
  };
64
63
  }
65
64
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahmedbaset/adminjs-hono",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "AdminJS adapter for Hono web framework",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -36,6 +36,7 @@
36
36
  "scripts": {
37
37
  "dev": "rm -rf lib && tsc --watch",
38
38
  "build": "rm -rf lib && tsc",
39
+ "prepublish": "pnpm run build",
39
40
  "test": "vitest run",
40
41
  "test:watch": "vitest",
41
42
  "lint": "eslint './**/*.ts'",
@@ -55,7 +55,7 @@ export function routeHandler(
55
55
  }
56
56
 
57
57
  // Execute the controller action
58
- const html = await controller[route.action](
58
+ const result = await controller[route.action](
59
59
  {
60
60
  ...c.req,
61
61
  params,
@@ -65,19 +65,19 @@ export function routeHandler(
65
65
  },
66
66
  c.res
67
67
  )
68
-
69
- // Set Content-Type header if specified
68
+
70
69
  if (route.contentType) {
71
- c.header('Content-Type', route.contentType)
70
+ c.header("Content-Type", route.contentType);
72
71
  }
73
-
74
- // Return response
75
- if (html) {
76
- return c.body(html)
72
+
73
+ // Return JSON or HTML based on route
74
+ if (
75
+ route.contentType === "application/json" ||
76
+ route.path.startsWith("/api")
77
+ ) {
78
+ return c.json(result);
77
79
  }
78
-
79
- // If no response body, return empty response
80
- return c.body(null)
80
+ return c.html(result);
81
81
  }
82
82
  }
83
83