@easydocs/express 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,52 @@
1
+ # @easydocs/express
2
+
3
+ EasyDocs middleware for [Express](https://expressjs.com/).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @easydocs/express
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import express from 'express'
15
+ import { easydocs } from '@easydocs/express'
16
+
17
+ const app = express()
18
+ app.use(express.json())
19
+ app.use(easydocs())
20
+
21
+ // Your routes — nothing changes here
22
+ app.get('/users', (req, res) => res.json({ users: [] }))
23
+
24
+ app.listen(3000)
25
+ ```
26
+
27
+ The documentation dashboard runs at `http://localhost:4999` (start it with `npx @easydocs/dashboard` or run `apps/dashboard` in dev).
28
+
29
+ ## Configuration
30
+
31
+ ```ts
32
+ app.use(easydocs({
33
+ ai: {
34
+ provider: 'anthropic', // 'openai' | 'anthropic' | 'ollama'
35
+ model: 'claude-3-5-sonnet-20241022',
36
+ },
37
+ storage: {
38
+ url: 'file:/path/to/custom.sqlite',
39
+ },
40
+ capture: {
41
+ ignoreRoutes: ['/health', '/metrics'],
42
+ },
43
+ }))
44
+ ```
45
+
46
+ ## Environment Variables
47
+
48
+ | Variable | Description |
49
+ |----------|-------------|
50
+ | `OPENAI_API_KEY` | OpenAI API key (auto-detected) |
51
+ | `ANTHROPIC_API_KEY` | Anthropic API key (auto-detected) |
52
+ | `EASYDOCS_DB_URL` | SQLite path, e.g. `file:~/.easydocs/db.sqlite` |
package/dist/index.cjs ADDED
@@ -0,0 +1,56 @@
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 function easydocsMiddleware(req, res, next) {
29
+ const startedAt = Date.now();
30
+ const originalJson = res.json.bind(res);
31
+ res.json = function(body) {
32
+ (0, import_core.capture)(
33
+ {
34
+ method: req.method,
35
+ path: req.route?.path ?? req.path,
36
+ query: req.query,
37
+ params: req.params,
38
+ body: req.body,
39
+ response: body,
40
+ status: res.statusCode,
41
+ requestHeaders: req.headers,
42
+ responseHeaders: res.getHeaders(),
43
+ durationMs: Date.now() - startedAt
44
+ },
45
+ config
46
+ );
47
+ return originalJson(body);
48
+ };
49
+ next();
50
+ };
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ easydocs
55
+ });
56
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { capture } from '@easydocs/core'\nimport type { EasyDocsConfig } from '@easydocs/core'\nimport type { Request, Response, NextFunction } from 'express'\n\nexport function easydocs(config?: EasyDocsConfig) {\n return function easydocsMiddleware(req: Request, res: Response, next: NextFunction) {\n const startedAt = Date.now()\n const originalJson = res.json.bind(res)\n\n res.json = function (body: unknown) {\n capture(\n {\n method: req.method as import('@easydocs/core').HttpMethod,\n path: req.route?.path ?? req.path,\n query: req.query as Record<string, string>,\n params: req.params as Record<string, string>,\n body: req.body,\n response: body,\n status: res.statusCode,\n requestHeaders: req.headers as Record<string, string>,\n responseHeaders: res.getHeaders() as Record<string, string>,\n durationMs: Date.now() - startedAt,\n },\n config\n )\n return originalJson(body)\n }\n\n next()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAIjB,SAAS,SAAS,QAAyB;AAChD,SAAO,SAAS,mBAAmB,KAAc,KAAe,MAAoB;AAClF,UAAM,YAAY,KAAK,IAAI;AAC3B,UAAM,eAAe,IAAI,KAAK,KAAK,GAAG;AAEtC,QAAI,OAAO,SAAU,MAAe;AAClC;AAAA,QACE;AAAA,UACE,QAAQ,IAAI;AAAA,UACZ,MAAM,IAAI,OAAO,QAAQ,IAAI;AAAA,UAC7B,OAAO,IAAI;AAAA,UACX,QAAQ,IAAI;AAAA,UACZ,MAAM,IAAI;AAAA,UACV,UAAU;AAAA,UACV,QAAQ,IAAI;AAAA,UACZ,gBAAgB,IAAI;AAAA,UACpB,iBAAiB,IAAI,WAAW;AAAA,UAChC,YAAY,KAAK,IAAI,IAAI;AAAA,QAC3B;AAAA,QACA;AAAA,MACF;AACA,aAAO,aAAa,IAAI;AAAA,IAC1B;AAEA,SAAK;AAAA,EACP;AACF;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { EasyDocsConfig } from '@easydocs/core';
2
+ import { Request, Response, NextFunction } from 'express';
3
+
4
+ declare function easydocs(config?: EasyDocsConfig): (req: Request, res: Response, next: NextFunction) => void;
5
+
6
+ export { easydocs };
@@ -0,0 +1,6 @@
1
+ import { EasyDocsConfig } from '@easydocs/core';
2
+ import { Request, Response, NextFunction } from 'express';
3
+
4
+ declare function easydocs(config?: EasyDocsConfig): (req: Request, res: Response, next: NextFunction) => void;
5
+
6
+ export { easydocs };
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ // src/index.ts
2
+ import { capture } from "@easydocs/core";
3
+ function easydocs(config) {
4
+ return function easydocsMiddleware(req, res, next) {
5
+ const startedAt = Date.now();
6
+ const originalJson = res.json.bind(res);
7
+ res.json = function(body) {
8
+ capture(
9
+ {
10
+ method: req.method,
11
+ path: req.route?.path ?? req.path,
12
+ query: req.query,
13
+ params: req.params,
14
+ body: req.body,
15
+ response: body,
16
+ status: res.statusCode,
17
+ requestHeaders: req.headers,
18
+ responseHeaders: res.getHeaders(),
19
+ durationMs: Date.now() - startedAt
20
+ },
21
+ config
22
+ );
23
+ return originalJson(body);
24
+ };
25
+ next();
26
+ };
27
+ }
28
+ export {
29
+ easydocs
30
+ };
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { capture } from '@easydocs/core'\nimport type { EasyDocsConfig } from '@easydocs/core'\nimport type { Request, Response, NextFunction } from 'express'\n\nexport function easydocs(config?: EasyDocsConfig) {\n return function easydocsMiddleware(req: Request, res: Response, next: NextFunction) {\n const startedAt = Date.now()\n const originalJson = res.json.bind(res)\n\n res.json = function (body: unknown) {\n capture(\n {\n method: req.method as import('@easydocs/core').HttpMethod,\n path: req.route?.path ?? req.path,\n query: req.query as Record<string, string>,\n params: req.params as Record<string, string>,\n body: req.body,\n response: body,\n status: res.statusCode,\n requestHeaders: req.headers as Record<string, string>,\n responseHeaders: res.getHeaders() as Record<string, string>,\n durationMs: Date.now() - startedAt,\n },\n config\n )\n return originalJson(body)\n }\n\n next()\n }\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAIjB,SAAS,SAAS,QAAyB;AAChD,SAAO,SAAS,mBAAmB,KAAc,KAAe,MAAoB;AAClF,UAAM,YAAY,KAAK,IAAI;AAC3B,UAAM,eAAe,IAAI,KAAK,KAAK,GAAG;AAEtC,QAAI,OAAO,SAAU,MAAe;AAClC;AAAA,QACE;AAAA,UACE,QAAQ,IAAI;AAAA,UACZ,MAAM,IAAI,OAAO,QAAQ,IAAI;AAAA,UAC7B,OAAO,IAAI;AAAA,UACX,QAAQ,IAAI;AAAA,UACZ,MAAM,IAAI;AAAA,UACV,UAAU;AAAA,UACV,QAAQ,IAAI;AAAA,UACZ,gBAAgB,IAAI;AAAA,UACpB,iBAAiB,IAAI,WAAW;AAAA,UAChC,YAAY,KAAK,IAAI,IAAI;AAAA,QAC3B;AAAA,QACA;AAAA,MACF;AACA,aAAO,aAAa,IAAI;AAAA,IAC1B;AAEA,SAAK;AAAA,EACP;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@easydocs/express",
3
+ "version": "0.1.4",
4
+ "files": [
5
+ "dist",
6
+ "README.md"
7
+ ],
8
+ "description": "EasyDocs middleware for Express",
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
+ "express": ">=4.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/express": "^5.0.0",
28
+ "express": "^5.0.0",
29
+ "tsup": "^8.3.0",
30
+ "typescript": "^5"
31
+ },
32
+ "scripts": {
33
+ "build": "tsup",
34
+ "dev": "tsup --watch",
35
+ "typecheck": "tsc --noEmit"
36
+ }
37
+ }