@easydocs/elysia 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 +21 -0
- package/README.md +42 -0
- package/dist/index.cjs +64 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
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,42 @@
|
|
|
1
|
+
# @easydocs/elysia
|
|
2
|
+
|
|
3
|
+
EasyDocs plugin for [Elysia](https://elysiajs.com/) (Bun-native).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @easydocs/elysia
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Elysia } from 'elysia'
|
|
15
|
+
import { easydocs } from '@easydocs/elysia'
|
|
16
|
+
|
|
17
|
+
const app = new Elysia()
|
|
18
|
+
.use(easydocs())
|
|
19
|
+
.get('/users', () => ({ users: [] }))
|
|
20
|
+
.listen(3000)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
app.use(easydocs({
|
|
27
|
+
ai: { provider: 'openai', model: 'gpt-4o' },
|
|
28
|
+
capture: { ignoreRoutes: ['/health'] },
|
|
29
|
+
}))
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## View your docs
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install -D @easydocs/dashboard
|
|
36
|
+
npx easydocs dashboard
|
|
37
|
+
|
|
38
|
+
# Or export to a file
|
|
39
|
+
npx easydocs export > openapi.json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
See [@easydocs/core](../core) for the full configuration reference.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
var import_elysia = require("elysia");
|
|
28
|
+
function easydocs(config) {
|
|
29
|
+
return new import_elysia.Elysia({ name: "@easydocs/elysia" }).onAfterHandle(
|
|
30
|
+
{ as: "global" },
|
|
31
|
+
async ({ request, response, set, path, params, query, body }) => {
|
|
32
|
+
let responseBody = null;
|
|
33
|
+
if (response instanceof Response) {
|
|
34
|
+
try {
|
|
35
|
+
responseBody = await response.clone().json();
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
responseBody = response;
|
|
40
|
+
}
|
|
41
|
+
const status = response instanceof Response ? response.status : set.status ?? 200;
|
|
42
|
+
(0, import_core.capture)(
|
|
43
|
+
{
|
|
44
|
+
method: request.method,
|
|
45
|
+
path,
|
|
46
|
+
query,
|
|
47
|
+
params,
|
|
48
|
+
body,
|
|
49
|
+
response: responseBody,
|
|
50
|
+
status,
|
|
51
|
+
requestHeaders: Object.fromEntries(request.headers.entries()),
|
|
52
|
+
responseHeaders: response instanceof Response ? Object.fromEntries(response.headers.entries()) : set.headers ?? {},
|
|
53
|
+
durationMs: 0
|
|
54
|
+
},
|
|
55
|
+
config
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
easydocs
|
|
63
|
+
});
|
|
64
|
+
//# 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 { Elysia } from 'elysia'\n\nexport function easydocs(config?: EasyDocsConfig) {\n return new Elysia({ name: '@easydocs/elysia' }).onAfterHandle(\n { as: 'global' },\n async ({ request, response, set, path, params, query, body }) => {\n let responseBody: unknown = null\n if (response instanceof Response) {\n try {\n responseBody = await response.clone().json()\n } catch {\n // non-JSON\n }\n } else {\n responseBody = response\n }\n\n const status =\n response instanceof Response ? response.status : (set.status as number | undefined) ?? 200\n\n capture(\n {\n method: request.method as HttpMethod,\n path,\n query: query as Record<string, string>,\n params: params as Record<string, string>,\n body,\n response: responseBody,\n status,\n requestHeaders: Object.fromEntries(request.headers.entries()),\n responseHeaders:\n response instanceof Response\n ? Object.fromEntries(response.headers.entries())\n : (set.headers as Record<string, string>) ?? {},\n durationMs: 0,\n },\n config\n )\n }\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,oBAAuB;AAEhB,SAAS,SAAS,QAAyB;AAChD,SAAO,IAAI,qBAAO,EAAE,MAAM,mBAAmB,CAAC,EAAE;AAAA,IAC9C,EAAE,IAAI,SAAS;AAAA,IACf,OAAO,EAAE,SAAS,UAAU,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;AAC/D,UAAI,eAAwB;AAC5B,UAAI,oBAAoB,UAAU;AAChC,YAAI;AACF,yBAAe,MAAM,SAAS,MAAM,EAAE,KAAK;AAAA,QAC7C,QAAQ;AAAA,QAER;AAAA,MACF,OAAO;AACL,uBAAe;AAAA,MACjB;AAEA,YAAM,SACJ,oBAAoB,WAAW,SAAS,SAAU,IAAI,UAAiC;AAEzF;AAAA,QACE;AAAA,UACE,QAAQ,QAAQ;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,UAAU;AAAA,UACV;AAAA,UACA,gBAAgB,OAAO,YAAY,QAAQ,QAAQ,QAAQ,CAAC;AAAA,UAC5D,iBACE,oBAAoB,WAChB,OAAO,YAAY,SAAS,QAAQ,QAAQ,CAAC,IAC5C,IAAI,WAAsC,CAAC;AAAA,UAClD,YAAY;AAAA,QACd;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EasyDocsConfig } from '@easydocs/core';
|
|
2
|
+
import { Elysia } from 'elysia';
|
|
3
|
+
|
|
4
|
+
declare function easydocs(config?: EasyDocsConfig): Elysia<"", {
|
|
5
|
+
decorator: {};
|
|
6
|
+
store: {};
|
|
7
|
+
derive: {};
|
|
8
|
+
resolve: {};
|
|
9
|
+
}, {
|
|
10
|
+
typebox: {};
|
|
11
|
+
error: {};
|
|
12
|
+
}, {
|
|
13
|
+
schema: {};
|
|
14
|
+
standaloneSchema: {};
|
|
15
|
+
macro: {};
|
|
16
|
+
macroFn: {};
|
|
17
|
+
parser: {};
|
|
18
|
+
response: {};
|
|
19
|
+
}, {}, {
|
|
20
|
+
derive: {};
|
|
21
|
+
resolve: {};
|
|
22
|
+
schema: {};
|
|
23
|
+
standaloneSchema: {};
|
|
24
|
+
response: {};
|
|
25
|
+
}, {
|
|
26
|
+
derive: {};
|
|
27
|
+
resolve: {};
|
|
28
|
+
schema: {};
|
|
29
|
+
standaloneSchema: {};
|
|
30
|
+
response: {};
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
export { easydocs };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EasyDocsConfig } from '@easydocs/core';
|
|
2
|
+
import { Elysia } from 'elysia';
|
|
3
|
+
|
|
4
|
+
declare function easydocs(config?: EasyDocsConfig): Elysia<"", {
|
|
5
|
+
decorator: {};
|
|
6
|
+
store: {};
|
|
7
|
+
derive: {};
|
|
8
|
+
resolve: {};
|
|
9
|
+
}, {
|
|
10
|
+
typebox: {};
|
|
11
|
+
error: {};
|
|
12
|
+
}, {
|
|
13
|
+
schema: {};
|
|
14
|
+
standaloneSchema: {};
|
|
15
|
+
macro: {};
|
|
16
|
+
macroFn: {};
|
|
17
|
+
parser: {};
|
|
18
|
+
response: {};
|
|
19
|
+
}, {}, {
|
|
20
|
+
derive: {};
|
|
21
|
+
resolve: {};
|
|
22
|
+
schema: {};
|
|
23
|
+
standaloneSchema: {};
|
|
24
|
+
response: {};
|
|
25
|
+
}, {
|
|
26
|
+
derive: {};
|
|
27
|
+
resolve: {};
|
|
28
|
+
schema: {};
|
|
29
|
+
standaloneSchema: {};
|
|
30
|
+
response: {};
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
export { easydocs };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { capture } from "@easydocs/core";
|
|
3
|
+
import { Elysia } from "elysia";
|
|
4
|
+
function easydocs(config) {
|
|
5
|
+
return new Elysia({ name: "@easydocs/elysia" }).onAfterHandle(
|
|
6
|
+
{ as: "global" },
|
|
7
|
+
async ({ request, response, set, path, params, query, body }) => {
|
|
8
|
+
let responseBody = null;
|
|
9
|
+
if (response instanceof Response) {
|
|
10
|
+
try {
|
|
11
|
+
responseBody = await response.clone().json();
|
|
12
|
+
} catch {
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
responseBody = response;
|
|
16
|
+
}
|
|
17
|
+
const status = response instanceof Response ? response.status : set.status ?? 200;
|
|
18
|
+
capture(
|
|
19
|
+
{
|
|
20
|
+
method: request.method,
|
|
21
|
+
path,
|
|
22
|
+
query,
|
|
23
|
+
params,
|
|
24
|
+
body,
|
|
25
|
+
response: responseBody,
|
|
26
|
+
status,
|
|
27
|
+
requestHeaders: Object.fromEntries(request.headers.entries()),
|
|
28
|
+
responseHeaders: response instanceof Response ? Object.fromEntries(response.headers.entries()) : set.headers ?? {},
|
|
29
|
+
durationMs: 0
|
|
30
|
+
},
|
|
31
|
+
config
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
easydocs
|
|
38
|
+
};
|
|
39
|
+
//# 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 { Elysia } from 'elysia'\n\nexport function easydocs(config?: EasyDocsConfig) {\n return new Elysia({ name: '@easydocs/elysia' }).onAfterHandle(\n { as: 'global' },\n async ({ request, response, set, path, params, query, body }) => {\n let responseBody: unknown = null\n if (response instanceof Response) {\n try {\n responseBody = await response.clone().json()\n } catch {\n // non-JSON\n }\n } else {\n responseBody = response\n }\n\n const status =\n response instanceof Response ? response.status : (set.status as number | undefined) ?? 200\n\n capture(\n {\n method: request.method as HttpMethod,\n path,\n query: query as Record<string, string>,\n params: params as Record<string, string>,\n body,\n response: responseBody,\n status,\n requestHeaders: Object.fromEntries(request.headers.entries()),\n responseHeaders:\n response instanceof Response\n ? Object.fromEntries(response.headers.entries())\n : (set.headers as Record<string, string>) ?? {},\n durationMs: 0,\n },\n config\n )\n }\n )\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAExB,SAAS,cAAc;AAEhB,SAAS,SAAS,QAAyB;AAChD,SAAO,IAAI,OAAO,EAAE,MAAM,mBAAmB,CAAC,EAAE;AAAA,IAC9C,EAAE,IAAI,SAAS;AAAA,IACf,OAAO,EAAE,SAAS,UAAU,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;AAC/D,UAAI,eAAwB;AAC5B,UAAI,oBAAoB,UAAU;AAChC,YAAI;AACF,yBAAe,MAAM,SAAS,MAAM,EAAE,KAAK;AAAA,QAC7C,QAAQ;AAAA,QAER;AAAA,MACF,OAAO;AACL,uBAAe;AAAA,MACjB;AAEA,YAAM,SACJ,oBAAoB,WAAW,SAAS,SAAU,IAAI,UAAiC;AAEzF;AAAA,QACE;AAAA,UACE,QAAQ,QAAQ;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,UAAU;AAAA,UACV;AAAA,UACA,gBAAgB,OAAO,YAAY,QAAQ,QAAQ,QAAQ,CAAC;AAAA,UAC5D,iBACE,oBAAoB,WAChB,OAAO,YAAY,SAAS,QAAQ,QAAQ,CAAC,IAC5C,IAAI,WAAsC,CAAC;AAAA,UAClD,YAAY;AAAA,QACd;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@easydocs/elysia",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist",
|
|
6
|
+
"README.md"
|
|
7
|
+
],
|
|
8
|
+
"description": "EasyDocs plugin for Elysia (Bun)",
|
|
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
|
+
"elysia": ">=1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"elysia": "^1.2.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
|
+
}
|