@xframework/hono 0.4.0
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/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +41 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -0
- package/src/__tests__/index.test.ts +43 -0
- package/src/index.ts +16 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +3 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
> @xframework/hono@0.4.0 build /home/runner/work/x/x/packages/@xframework/hono
|
3
|
+
> tsup
|
4
|
+
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
7
|
+
[34mCLI[39m tsup v8.3.5
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/x/x/packages/@xframework/hono/tsup.config.ts
|
9
|
+
[34mCLI[39m Target: esnext
|
10
|
+
[34mCLI[39m Cleaning output folder
|
11
|
+
[34mCJS[39m Build start
|
12
|
+
[34mESM[39m Build start
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m1.29 KB[39m
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m675.00 B[39m
|
15
|
+
[32mCJS[39m ⚡️ Build success in 36ms
|
16
|
+
[32mESM[39m [1mdist/index.js [22m[32m289.00 B[39m
|
17
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m635.00 B[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 38ms
|
19
|
+
[34mDTS[39m Build start
|
20
|
+
[32mDTS[39m ⚡️ Build success in 4368ms
|
21
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m335.00 B[39m
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m335.00 B[39m
|
package/CHANGELOG.md
ADDED
package/dist/index.cjs
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/index.ts
|
21
|
+
var index_exports = {};
|
22
|
+
__export(index_exports, {
|
23
|
+
HonoAdapter: () => HonoAdapter
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
26
|
+
var import_adapter = require("@xframework/x/adapter");
|
27
|
+
var HonoAdapter = class extends import_adapter.SyncAdapter {
|
28
|
+
hono;
|
29
|
+
constructor({ hono }) {
|
30
|
+
super();
|
31
|
+
this.hono = hono;
|
32
|
+
}
|
33
|
+
export() {
|
34
|
+
return this.hono;
|
35
|
+
}
|
36
|
+
};
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
38
|
+
0 && (module.exports = {
|
39
|
+
HonoAdapter
|
40
|
+
});
|
41
|
+
//# sourceMappingURL=index.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Hono } from \"hono\";\nimport { SyncAdapter } from \"@xframework/x/adapter\";\n\nexport class HonoAdapter<\n UserHonoInstance extends Hono,\n> extends SyncAdapter<UserHonoInstance> {\n public hono: UserHonoInstance;\n constructor({ hono }: { hono: UserHonoInstance }) {\n super();\n this.hono = hono;\n }\n\n export() {\n return this.hono;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA4B;AAErB,IAAM,cAAN,cAEG,2BAA8B;AAAA,EAC/B;AAAA,EACP,YAAY,EAAE,KAAK,GAA+B;AAChD,UAAM;AACN,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,SAAS;AACP,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Hono } from 'hono';
|
2
|
+
import { SyncAdapter } from '@xframework/x/adapter';
|
3
|
+
|
4
|
+
declare class HonoAdapter<UserHonoInstance extends Hono> extends SyncAdapter<UserHonoInstance> {
|
5
|
+
hono: UserHonoInstance;
|
6
|
+
constructor({ hono }: {
|
7
|
+
hono: UserHonoInstance;
|
8
|
+
});
|
9
|
+
export(): UserHonoInstance;
|
10
|
+
}
|
11
|
+
|
12
|
+
export { HonoAdapter };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Hono } from 'hono';
|
2
|
+
import { SyncAdapter } from '@xframework/x/adapter';
|
3
|
+
|
4
|
+
declare class HonoAdapter<UserHonoInstance extends Hono> extends SyncAdapter<UserHonoInstance> {
|
5
|
+
hono: UserHonoInstance;
|
6
|
+
constructor({ hono }: {
|
7
|
+
hono: UserHonoInstance;
|
8
|
+
});
|
9
|
+
export(): UserHonoInstance;
|
10
|
+
}
|
11
|
+
|
12
|
+
export { HonoAdapter };
|
package/dist/index.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
// src/index.ts
|
2
|
+
import { SyncAdapter } from "@xframework/x/adapter";
|
3
|
+
var HonoAdapter = class extends SyncAdapter {
|
4
|
+
hono;
|
5
|
+
constructor({ hono }) {
|
6
|
+
super();
|
7
|
+
this.hono = hono;
|
8
|
+
}
|
9
|
+
export() {
|
10
|
+
return this.hono;
|
11
|
+
}
|
12
|
+
};
|
13
|
+
export {
|
14
|
+
HonoAdapter
|
15
|
+
};
|
16
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Hono } from \"hono\";\nimport { SyncAdapter } from \"@xframework/x/adapter\";\n\nexport class HonoAdapter<\n UserHonoInstance extends Hono,\n> extends SyncAdapter<UserHonoInstance> {\n public hono: UserHonoInstance;\n constructor({ hono }: { hono: UserHonoInstance }) {\n super();\n this.hono = hono;\n }\n\n export() {\n return this.hono;\n }\n}\n"],"mappings":";AACA,SAAS,mBAAmB;AAErB,IAAM,cAAN,cAEG,YAA8B;AAAA,EAC/B;AAAA,EACP,YAAY,EAAE,KAAK,GAA+B;AAChD,UAAM;AACN,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,SAAS;AACP,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/package.json
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"name": "@xframework/hono",
|
3
|
+
"version": "0.4.0",
|
4
|
+
"type": "module",
|
5
|
+
"exports": {
|
6
|
+
".": {
|
7
|
+
"types": "./dist/index.d.ts",
|
8
|
+
"require": "./dist/index.cjs",
|
9
|
+
"import": "./dist/index.js"
|
10
|
+
}
|
11
|
+
},
|
12
|
+
"main": "./dist/index.cjs",
|
13
|
+
"module": "./dist/index.js",
|
14
|
+
"types": "./dist/index.d.ts",
|
15
|
+
"publishConfig": {
|
16
|
+
"access": "public"
|
17
|
+
},
|
18
|
+
"dependencies": {
|
19
|
+
"@xframework/x": "0.4.0"
|
20
|
+
},
|
21
|
+
"peerDependencies": {
|
22
|
+
"hono": ">=4.0.0"
|
23
|
+
},
|
24
|
+
"devDependencies": {
|
25
|
+
"@types/node": "^20.11.24",
|
26
|
+
"tsup": "^8.2.4",
|
27
|
+
"typescript": "^5.5.4"
|
28
|
+
},
|
29
|
+
"scripts": {
|
30
|
+
"build": "tsup",
|
31
|
+
"dev": "tsup --watch"
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { Hono } from "hono";
|
2
|
+
import { expect, it, describe } from "vitest";
|
3
|
+
import { createX } from "@xframework/x";
|
4
|
+
import { HonoAdapter } from "../index";
|
5
|
+
import { hc } from "hono/client";
|
6
|
+
|
7
|
+
describe("HonoAdapter", () => {
|
8
|
+
it("should properly initialize and export Hono instance", () => {
|
9
|
+
const hono = new Hono();
|
10
|
+
const adapter = new HonoAdapter({ hono });
|
11
|
+
|
12
|
+
expect(adapter.hono).toBe(hono);
|
13
|
+
expect(adapter.export()).toBe(hono);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("should preserve Hono types and route handlers", () => {
|
17
|
+
const hono = new Hono().get("/hello/:name", (c) => {
|
18
|
+
const name = c.req.param("name");
|
19
|
+
return c.json({ message: `Hello ${name}!` });
|
20
|
+
});
|
21
|
+
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
23
|
+
const x = createX()
|
24
|
+
.syncAdapter("hono", () => new HonoAdapter({ hono }))
|
25
|
+
.build();
|
26
|
+
|
27
|
+
type AppType = typeof x.hono;
|
28
|
+
const client = hc<AppType>("/");
|
29
|
+
expect(client.hello[":name"].$get).toBeDefined();
|
30
|
+
});
|
31
|
+
|
32
|
+
it("should work with middleware and complex routes", () => {
|
33
|
+
const hono = new Hono()
|
34
|
+
.get("/api/users/:id", (c) => c.json({ id: c.req.param("id") }))
|
35
|
+
.post("/api/users", (c) => c.json({ status: "created" }));
|
36
|
+
|
37
|
+
const x = createX()
|
38
|
+
.syncAdapter("hono", () => new HonoAdapter({ hono }))
|
39
|
+
.build();
|
40
|
+
|
41
|
+
expect(x.hono.routes).toHaveLength(2);
|
42
|
+
});
|
43
|
+
});
|
package/src/index.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { Hono } from "hono";
|
2
|
+
import { SyncAdapter } from "@xframework/x/adapter";
|
3
|
+
|
4
|
+
export class HonoAdapter<
|
5
|
+
UserHonoInstance extends Hono,
|
6
|
+
> extends SyncAdapter<UserHonoInstance> {
|
7
|
+
public hono: UserHonoInstance;
|
8
|
+
constructor({ hono }: { hono: UserHonoInstance }) {
|
9
|
+
super();
|
10
|
+
this.hono = hono;
|
11
|
+
}
|
12
|
+
|
13
|
+
export() {
|
14
|
+
return this.hono;
|
15
|
+
}
|
16
|
+
}
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED