@easydocs/hono 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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 EasyDocs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @easydocs/hono
2
+
3
+ EasyDocs middleware for [Hono](https://hono.dev/). Works on Node.js, Cloudflare Workers, Bun, and Deno.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @easydocs/hono
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { Hono } from 'hono'
15
+ import { easydocs } from '@easydocs/hono'
16
+
17
+ const app = new Hono()
18
+ app.use(easydocs())
19
+
20
+ // Your routes — nothing changes here
21
+ app.get('/users', (c) => c.json({ users: [] }))
22
+
23
+ export default app
24
+ ```
25
+
26
+ ## Configuration
27
+
28
+ ```ts
29
+ app.use(easydocs({
30
+ ai: {
31
+ provider: 'ollama',
32
+ model: 'llama3.2',
33
+ baseUrl: 'http://localhost:11434/v1',
34
+ },
35
+ }))
36
+ ```
37
+
38
+ ## View your docs
39
+
40
+ ```bash
41
+ npm install -D @easydocs/dashboard
42
+ npx easydocs dashboard
43
+
44
+ # Or export to a file
45
+ npx easydocs export > openapi.json
46
+ ```
47
+
48
+ See [@easydocs/core](../core) for the full configuration reference.
package/dist/index.cjs ADDED
@@ -0,0 +1,60 @@
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
+ easydocs: () => easydocs
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_core = require("@easydocs/core");
27
+ function easydocs(config) {
28
+ return async function easydocsMiddleware(c, next) {
29
+ const startedAt = Date.now();
30
+ await next();
31
+ let responseBody;
32
+ try {
33
+ responseBody = await c.res.clone().json();
34
+ } catch {
35
+ responseBody = null;
36
+ }
37
+ const url = new URL(c.req.url);
38
+ const routePath = c.req.routePath ?? url.pathname;
39
+ (0, import_core.capture)(
40
+ {
41
+ method: c.req.method,
42
+ path: routePath,
43
+ query: Object.fromEntries(url.searchParams.entries()),
44
+ params: c.req.param(),
45
+ body: await c.req.raw.clone().json().catch(() => null),
46
+ response: responseBody,
47
+ status: c.res.status,
48
+ requestHeaders: Object.fromEntries(c.req.raw.headers.entries()),
49
+ responseHeaders: Object.fromEntries(c.res.headers.entries()),
50
+ durationMs: Date.now() - startedAt
51
+ },
52
+ config
53
+ );
54
+ };
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ easydocs
59
+ });
60
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { capture } from '@easydocs/core'\nimport type { EasyDocsConfig, HttpMethod } from '@easydocs/core'\nimport type { Context, Next } from 'hono'\n\nexport function easydocs(config?: EasyDocsConfig) {\n return async function easydocsMiddleware(c: Context, next: Next) {\n const startedAt = Date.now()\n await next()\n\n let responseBody: unknown\n try {\n responseBody = await c.res.clone().json()\n } catch {\n responseBody = null\n }\n\n const url = new URL(c.req.url)\n const routePath = c.req.routePath ?? url.pathname\n\n capture(\n {\n method: c.req.method as HttpMethod,\n path: routePath,\n query: Object.fromEntries(url.searchParams.entries()),\n params: c.req.param() as Record<string, string>,\n body: await c.req.raw.clone().json().catch(() => null),\n response: responseBody,\n status: c.res.status,\n requestHeaders: Object.fromEntries(c.req.raw.headers.entries()),\n responseHeaders: Object.fromEntries(c.res.headers.entries()),\n durationMs: Date.now() - startedAt,\n },\n config\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAIjB,SAAS,SAAS,QAAyB;AAChD,SAAO,eAAe,mBAAmB,GAAY,MAAY;AAC/D,UAAM,YAAY,KAAK,IAAI;AAC3B,UAAM,KAAK;AAEX,QAAI;AACJ,QAAI;AACF,qBAAe,MAAM,EAAE,IAAI,MAAM,EAAE,KAAK;AAAA,IAC1C,QAAQ;AACN,qBAAe;AAAA,IACjB;AAEA,UAAM,MAAM,IAAI,IAAI,EAAE,IAAI,GAAG;AAC7B,UAAM,YAAY,EAAE,IAAI,aAAa,IAAI;AAEzC;AAAA,MACE;AAAA,QACE,QAAQ,EAAE,IAAI;AAAA,QACd,MAAM;AAAA,QACN,OAAO,OAAO,YAAY,IAAI,aAAa,QAAQ,CAAC;AAAA,QACpD,QAAQ,EAAE,IAAI,MAAM;AAAA,QACpB,MAAM,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,IAAI;AAAA,QACrD,UAAU;AAAA,QACV,QAAQ,EAAE,IAAI;AAAA,QACd,gBAAgB,OAAO,YAAY,EAAE,IAAI,IAAI,QAAQ,QAAQ,CAAC;AAAA,QAC9D,iBAAiB,OAAO,YAAY,EAAE,IAAI,QAAQ,QAAQ,CAAC;AAAA,QAC3D,YAAY,KAAK,IAAI,IAAI;AAAA,MAC3B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { EasyDocsConfig } from '@easydocs/core';
2
+ import { Context, Next } from 'hono';
3
+
4
+ declare function easydocs(config?: EasyDocsConfig): (c: Context, next: Next) => Promise<void>;
5
+
6
+ export { easydocs };
@@ -0,0 +1,6 @@
1
+ import { EasyDocsConfig } from '@easydocs/core';
2
+ import { Context, Next } from 'hono';
3
+
4
+ declare function easydocs(config?: EasyDocsConfig): (c: Context, next: Next) => Promise<void>;
5
+
6
+ export { easydocs };
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ // src/index.ts
2
+ import { capture } from "@easydocs/core";
3
+ function easydocs(config) {
4
+ return async function easydocsMiddleware(c, next) {
5
+ const startedAt = Date.now();
6
+ await next();
7
+ let responseBody;
8
+ try {
9
+ responseBody = await c.res.clone().json();
10
+ } catch {
11
+ responseBody = null;
12
+ }
13
+ const url = new URL(c.req.url);
14
+ const routePath = c.req.routePath ?? url.pathname;
15
+ capture(
16
+ {
17
+ method: c.req.method,
18
+ path: routePath,
19
+ query: Object.fromEntries(url.searchParams.entries()),
20
+ params: c.req.param(),
21
+ body: await c.req.raw.clone().json().catch(() => null),
22
+ response: responseBody,
23
+ status: c.res.status,
24
+ requestHeaders: Object.fromEntries(c.req.raw.headers.entries()),
25
+ responseHeaders: Object.fromEntries(c.res.headers.entries()),
26
+ durationMs: Date.now() - startedAt
27
+ },
28
+ config
29
+ );
30
+ };
31
+ }
32
+ export {
33
+ easydocs
34
+ };
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { capture } from '@easydocs/core'\nimport type { EasyDocsConfig, HttpMethod } from '@easydocs/core'\nimport type { Context, Next } from 'hono'\n\nexport function easydocs(config?: EasyDocsConfig) {\n return async function easydocsMiddleware(c: Context, next: Next) {\n const startedAt = Date.now()\n await next()\n\n let responseBody: unknown\n try {\n responseBody = await c.res.clone().json()\n } catch {\n responseBody = null\n }\n\n const url = new URL(c.req.url)\n const routePath = c.req.routePath ?? url.pathname\n\n capture(\n {\n method: c.req.method as HttpMethod,\n path: routePath,\n query: Object.fromEntries(url.searchParams.entries()),\n params: c.req.param() as Record<string, string>,\n body: await c.req.raw.clone().json().catch(() => null),\n response: responseBody,\n status: c.res.status,\n requestHeaders: Object.fromEntries(c.req.raw.headers.entries()),\n responseHeaders: Object.fromEntries(c.res.headers.entries()),\n durationMs: Date.now() - startedAt,\n },\n config\n )\n }\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAIjB,SAAS,SAAS,QAAyB;AAChD,SAAO,eAAe,mBAAmB,GAAY,MAAY;AAC/D,UAAM,YAAY,KAAK,IAAI;AAC3B,UAAM,KAAK;AAEX,QAAI;AACJ,QAAI;AACF,qBAAe,MAAM,EAAE,IAAI,MAAM,EAAE,KAAK;AAAA,IAC1C,QAAQ;AACN,qBAAe;AAAA,IACjB;AAEA,UAAM,MAAM,IAAI,IAAI,EAAE,IAAI,GAAG;AAC7B,UAAM,YAAY,EAAE,IAAI,aAAa,IAAI;AAEzC;AAAA,MACE;AAAA,QACE,QAAQ,EAAE,IAAI;AAAA,QACd,MAAM;AAAA,QACN,OAAO,OAAO,YAAY,IAAI,aAAa,QAAQ,CAAC;AAAA,QACpD,QAAQ,EAAE,IAAI,MAAM;AAAA,QACpB,MAAM,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,IAAI;AAAA,QACrD,UAAU;AAAA,QACV,QAAQ,EAAE,IAAI;AAAA,QACd,gBAAgB,OAAO,YAAY,EAAE,IAAI,IAAI,QAAQ,QAAQ,CAAC;AAAA,QAC9D,iBAAiB,OAAO,YAAY,EAAE,IAAI,QAAQ,QAAQ,CAAC;AAAA,QAC3D,YAAY,KAAK,IAAI,IAAI;AAAA,MAC3B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@easydocs/hono",
3
+ "version": "0.1.4",
4
+ "files": [
5
+ "dist",
6
+ "README.md"
7
+ ],
8
+ "description": "EasyDocs middleware for Hono",
9
+ "type": "module",
10
+ "main": "./dist/index.cjs",
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs",
17
+ "types": "./dist/index.d.ts"
18
+ }
19
+ },
20
+ "dependencies": {
21
+ "@easydocs/core": "0.1.4"
22
+ },
23
+ "peerDependencies": {
24
+ "hono": ">=4.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "hono": "^4.7.0",
28
+ "tsup": "^8.3.0",
29
+ "typescript": "^5"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "dev": "tsup --watch",
34
+ "typecheck": "tsc --noEmit"
35
+ }
36
+ }