@rdyl/node-koa-controller 0.3.9 → 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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 0.3.9 (2025-09-05)
1
+ # 0.4.0 (2025-12-30)
2
2
 
3
3
 
4
4
 
package/dist/cache.js CHANGED
@@ -42,6 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  var fs_1 = __importDefault(require("fs"));
43
43
  var path_1 = require("path");
44
44
  var utils_1 = require("./utils");
45
+ var docs_1 = require("./docs");
45
46
  var ASTCache = /** @class */ (function () {
46
47
  function ASTCache() {
47
48
  }
@@ -146,6 +147,19 @@ var ASTCache = /** @class */ (function () {
146
147
  }); });
147
148
  });
148
149
  });
150
+ router.get((0, path_1.join)("/" + ASTCache.prefix, docs_1.DocsHtml.docs_path), function (ctx) { return __awaiter(_this, void 0, void 0, function () {
151
+ var __html__;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0: return [4 /*yield*/, docs_1.DocsHtml.load()];
155
+ case 1:
156
+ __html__ = _a.sent();
157
+ ctx.type = "html";
158
+ ctx.body = __html__;
159
+ return [2 /*return*/];
160
+ }
161
+ });
162
+ }); });
149
163
  };
150
164
  ASTCache.logs = false;
151
165
  ASTCache.prefix = "";
@@ -39,12 +39,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.api_docs_path = void 0;
42
+ exports.DocsHtml = exports.api_docs_path = void 0;
43
43
  exports.getDocsHtml = getDocsHtml;
44
44
  var ejs_1 = __importDefault(require("ejs"));
45
45
  var path_1 = __importDefault(require("path"));
46
46
  var cache_1 = __importDefault(require("../cache"));
47
- var parse_1 = require("../docs/parse");
47
+ var parse_1 = require("./parse");
48
48
  exports.api_docs_path = "/api-docs.html";
49
49
  function getDocsHtml() {
50
50
  return __awaiter(this, void 0, void 0, function () {
@@ -61,3 +61,27 @@ function getDocsHtml() {
61
61
  });
62
62
  });
63
63
  }
64
+ exports.DocsHtml = {
65
+ docs_path: "/api-docs.html",
66
+ __html__: "",
67
+ load: function () {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ var treeData, _a;
70
+ return __generator(this, function (_b) {
71
+ switch (_b.label) {
72
+ case 0:
73
+ treeData = (0, parse_1.parseASTRoutes)(cache_1.default.routes);
74
+ if (!!this.__html__) return [3 /*break*/, 2];
75
+ _a = exports.DocsHtml;
76
+ return [4 /*yield*/, ejs_1.default.renderFile(path_1.default.resolve(__dirname, "./template.ejs"), {
77
+ treeData: treeData,
78
+ })];
79
+ case 1:
80
+ _a.__html__ = _b.sent();
81
+ _b.label = 2;
82
+ case 2: return [2 /*return*/, exports.DocsHtml.__html__];
83
+ }
84
+ });
85
+ });
86
+ },
87
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdyl/node-koa-controller",
3
- "version": "0.3.9",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -1,2 +1,7 @@
1
1
  export declare const api_docs_path = "/api-docs.html";
2
2
  export declare function getDocsHtml(): Promise<string>;
3
+ export declare const DocsHtml: {
4
+ docs_path: string;
5
+ __html__: string;
6
+ load(): Promise<string>;
7
+ };