@kitledger/server 0.0.3 → 0.0.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.
- package/dist/server.d.ts +3 -3
- package/dist/server.js +9 -11
- package/package.json +9 -9
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type KitledgerConfig } from "@kitledger/core";
|
|
2
|
+
import { StaticUIConfig } from "@kitledger/core/ui";
|
|
3
|
+
import { Hono } from "hono";
|
|
4
4
|
export type ServerOptions = {
|
|
5
5
|
systemConfig: KitledgerConfig;
|
|
6
6
|
runtime: "node";
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { serveStatic } from "@hono/node-server/serve-static";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
3
|
export function defineServerConfig(options) {
|
|
4
4
|
return options;
|
|
5
5
|
}
|
|
@@ -17,17 +17,15 @@ export function createServer(config) {
|
|
|
17
17
|
return c.json(config.systemConfig.entityModels);
|
|
18
18
|
});
|
|
19
19
|
// Remove trailing slash if path ends with '/'
|
|
20
|
-
const cleanPath = staticUI.basePath.endsWith(
|
|
21
|
-
? staticUI.basePath.slice(0, -1)
|
|
22
|
-
: staticUI.basePath;
|
|
20
|
+
const cleanPath = staticUI.basePath.endsWith("/") ? staticUI.basePath.slice(0, -1) : staticUI.basePath;
|
|
23
21
|
server.use(`${cleanPath}/*`, serveStatic({
|
|
24
22
|
root: staticUI.assetsPath,
|
|
25
23
|
rewriteRequestPath: (path) => {
|
|
26
|
-
const p = path.replace(new RegExp(`^${cleanPath}`),
|
|
27
|
-
if (p ===
|
|
28
|
-
return
|
|
24
|
+
const p = path.replace(new RegExp(`^${cleanPath}`), "").replace(/^\//, "");
|
|
25
|
+
if (p === "" || p === "index.html")
|
|
26
|
+
return "__404__";
|
|
29
27
|
return p;
|
|
30
|
-
}
|
|
28
|
+
},
|
|
31
29
|
}));
|
|
32
30
|
server.get(`${cleanPath}/*`, (c) => c.html(staticUI.htmlContent));
|
|
33
31
|
}
|
|
@@ -38,8 +36,8 @@ export function createServer(config) {
|
|
|
38
36
|
if (config.staticPaths) {
|
|
39
37
|
for (const staticPath of config.staticPaths) {
|
|
40
38
|
server.use(staticPath, serveStatic({
|
|
41
|
-
root:
|
|
42
|
-
rewriteRequestPath: (path) => path.replace(new RegExp(`^${staticPath}`),
|
|
39
|
+
root: ".",
|
|
40
|
+
rewriteRequestPath: (path) => path.replace(new RegExp(`^${staticPath}`), "").replace(/^\//, ""),
|
|
43
41
|
}));
|
|
44
42
|
}
|
|
45
43
|
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitledger/server",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"private": false,
|
|
3
5
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.0.3",
|
|
5
6
|
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"private": false,
|
|
10
|
-
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
12
|
-
},
|
|
13
7
|
"exports": {
|
|
14
8
|
".": {
|
|
15
9
|
"types": "./dist/server.d.ts",
|
|
16
10
|
"default": "./dist/server.js"
|
|
17
11
|
}
|
|
18
12
|
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
19
16
|
"dependencies": {
|
|
20
17
|
"@hono/node-server": "^1.19.6",
|
|
21
18
|
"hono": "^4.10.7",
|
|
22
|
-
"@kitledger/core": "0.0.
|
|
19
|
+
"@kitledger/core": "0.0.3"
|
|
23
20
|
},
|
|
24
21
|
"peerDependencies": {
|
|
25
22
|
"valibot": "^1.1.0"
|
|
26
23
|
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsc",
|
|
29
29
|
"typecheck": "tsc --noEmit"
|