@ahmedbaset/adminjs-hono 0.1.2 → 0.1.3
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/lib/buildRouter.js +7 -8
- package/package.json +2 -1
- package/src/buildRouter.ts +11 -11
package/lib/buildRouter.js
CHANGED
|
@@ -43,23 +43,22 @@ export function routeHandler(admin, route) {
|
|
|
43
43
|
...files,
|
|
44
44
|
};
|
|
45
45
|
// Execute the controller action
|
|
46
|
-
const
|
|
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(
|
|
54
|
+
c.header("Content-Type", route.contentType);
|
|
56
55
|
}
|
|
57
|
-
// Return
|
|
58
|
-
if (
|
|
59
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.3",
|
|
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'",
|
package/src/buildRouter.ts
CHANGED
|
@@ -55,7 +55,7 @@ export function routeHandler(
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Execute the controller action
|
|
58
|
-
const
|
|
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(
|
|
70
|
+
c.header("Content-Type", route.contentType);
|
|
72
71
|
}
|
|
73
|
-
|
|
74
|
-
// Return
|
|
75
|
-
if (
|
|
76
|
-
|
|
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
|
|