@kitledger/server 0.0.1 → 0.0.2
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/{core.d.ts → server.d.ts} +2 -2
- package/dist/{node.js → server.js} +15 -6
- package/package.json +5 -5
- package/dist/core.js +0 -14
- package/dist/node.d.ts +0 -2
|
@@ -3,10 +3,10 @@ import { type KitledgerConfig } from '@kitledger/core';
|
|
|
3
3
|
import { StaticUIConfig } from '@kitledger/core/ui';
|
|
4
4
|
export type ServerOptions = {
|
|
5
5
|
systemConfig: KitledgerConfig;
|
|
6
|
-
|
|
6
|
+
runtime: "node";
|
|
7
7
|
staticPaths?: string[];
|
|
8
8
|
staticUIs?: StaticUIConfig[];
|
|
9
9
|
};
|
|
10
10
|
export type ServerConfig = ServerOptions;
|
|
11
11
|
export declare function defineServerConfig(options: ServerOptions): ServerConfig;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function createServer(config: ServerConfig): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
1
2
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
2
|
-
|
|
3
|
+
export function defineServerConfig(options) {
|
|
4
|
+
return options;
|
|
5
|
+
}
|
|
3
6
|
export function createServer(config) {
|
|
4
|
-
const server =
|
|
7
|
+
const server = new Hono();
|
|
5
8
|
/**
|
|
6
9
|
* Static Apps Serving
|
|
7
10
|
*/
|
|
8
11
|
if (config.staticUIs) {
|
|
9
12
|
for (const staticUI of config.staticUIs) {
|
|
13
|
+
server.get(`${staticUI.serverPath}/transactions/models`, (c) => {
|
|
14
|
+
return c.json(config.systemConfig.transactionModels);
|
|
15
|
+
});
|
|
16
|
+
server.get(`${staticUI.serverPath}/entities/models`, (c) => {
|
|
17
|
+
return c.json(config.systemConfig.entityModels);
|
|
18
|
+
});
|
|
10
19
|
// Remove trailing slash if path ends with '/'
|
|
11
|
-
const cleanPath = staticUI.
|
|
12
|
-
? staticUI.
|
|
13
|
-
: staticUI.
|
|
20
|
+
const cleanPath = staticUI.basePath.endsWith('/')
|
|
21
|
+
? staticUI.basePath.slice(0, -1)
|
|
22
|
+
: staticUI.basePath;
|
|
14
23
|
server.get(cleanPath, (c) => c.redirect(cleanPath + '/'));
|
|
15
24
|
server.use(`${cleanPath}/*`, serveStatic({
|
|
16
25
|
root: staticUI.assetsPath,
|
|
@@ -35,5 +44,5 @@ export function createServer(config) {
|
|
|
35
44
|
}));
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
|
-
return server
|
|
47
|
+
return server;
|
|
39
48
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitledger/server",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
|
-
"
|
|
15
|
-
"types": "./dist/
|
|
16
|
-
"default": "./dist/
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/server.d.ts",
|
|
16
|
+
"default": "./dist/server.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@hono/node-server": "^1.19.6",
|
|
21
21
|
"hono": "^4.10.7",
|
|
22
|
-
"@kitledger/core": "0.0.
|
|
22
|
+
"@kitledger/core": "0.0.2"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"valibot": "^1.1.0"
|
package/dist/core.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Hono } from 'hono';
|
|
2
|
-
export function defineServerConfig(options) {
|
|
3
|
-
return options;
|
|
4
|
-
}
|
|
5
|
-
export function createBaseServer(config) {
|
|
6
|
-
const baseServer = new Hono();
|
|
7
|
-
baseServer.get(`${config.path}/transactions/models`, (c) => {
|
|
8
|
-
return c.json(config.systemConfig.transactionModels);
|
|
9
|
-
});
|
|
10
|
-
baseServer.get(`${config.path}/entities/models`, (c) => {
|
|
11
|
-
return c.json(config.systemConfig.entityModels);
|
|
12
|
-
});
|
|
13
|
-
return baseServer;
|
|
14
|
-
}
|
package/dist/node.d.ts
DELETED