@hedystia/swagger 1.10.0 → 1.10.2

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.
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ exports.__toESM = __toESM;
package/dist/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_plugin = require("./plugin.cjs");
3
+ exports.swagger = require_plugin.swagger;
@@ -0,0 +1,2 @@
1
+ import { swagger } from "./plugin.cjs";
2
+ export { swagger };
@@ -0,0 +1,2 @@
1
+ import { swagger } from "./plugin.mjs";
2
+ export { swagger };
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { swagger } from "./plugin.mjs";
2
+ export { swagger };
@@ -0,0 +1,41 @@
1
+ require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_swagger = require("./swagger.cjs");
3
+ let hedystia = require("hedystia");
4
+ //#region src/plugin.ts
5
+ /**
6
+ * Create Swagger plugin
7
+ * @param {SwaggerOptions} [options] - Swagger options
8
+ * @returns Plugin instance
9
+ */
10
+ function swagger(options = {}) {
11
+ const swaggerInstance = new require_swagger.Swagger(options);
12
+ const swaggerApp = new hedystia.Hedystia().get("/", () => {
13
+ return new Response(swaggerInstance.generateHTML(), { headers: { "Content-Type": "text/html" } });
14
+ }).get("/json", () => {
15
+ return swaggerInstance.getSpec();
16
+ });
17
+ function createPlugin(app) {
18
+ for (const route of app.routes) swaggerInstance.addRoute(route.method, route.path, {
19
+ params: route.schema.params,
20
+ query: route.schema.query,
21
+ body: route.schema.body,
22
+ response: route.schema.response
23
+ }, route.schema.description || `${route.method} ${route.path}`, route.schema.description, route.schema.tags);
24
+ for (const staticRoute of app.staticRoutes) swaggerInstance.addRoute("GET", staticRoute.path, {}, `Static route ${staticRoute.path}`);
25
+ for (const [path] of app.wsRoutes) swaggerInstance.addRoute("WS", path, {}, `WebSocket route ${path}`);
26
+ for (const [path, handlerData] of app.subscriptionHandlers) swaggerInstance.addRoute("SUB", path, {
27
+ params: handlerData.schema.params,
28
+ query: handlerData.schema.query,
29
+ headers: handlerData.schema.headers
30
+ }, handlerData.schema.description || `SUB ${path}`, handlerData.schema.description, handlerData.schema.tags);
31
+ return swaggerApp;
32
+ }
33
+ return {
34
+ plugin: createPlugin,
35
+ swagger: swaggerInstance
36
+ };
37
+ }
38
+ //#endregion
39
+ exports.swagger = swagger;
40
+
41
+ //# sourceMappingURL=plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs","names":["Swagger","Hedystia"],"sources":["../src/plugin.ts"],"sourcesContent":["import { Hedystia } from \"hedystia\";\nimport { Swagger, type SwaggerOptions } from \"./swagger\";\n\n/**\n * Create Swagger plugin\n * @param {SwaggerOptions} [options] - Swagger options\n * @returns Plugin instance\n */\nexport function swagger(options: SwaggerOptions = {}) {\n const swaggerInstance = new Swagger(options);\n\n const swaggerApp = new Hedystia()\n .get(\"/\", () => {\n return new Response(swaggerInstance.generateHTML(), {\n headers: { \"Content-Type\": \"text/html\" },\n });\n })\n .get(\"/json\", () => {\n return swaggerInstance.getSpec();\n });\n\n function createPlugin(app: Hedystia<any, any>) {\n for (const route of app.routes) {\n swaggerInstance.addRoute(\n route.method,\n route.path,\n {\n params: route.schema.params,\n query: route.schema.query,\n body: route.schema.body,\n response: route.schema.response,\n },\n route.schema.description || `${route.method} ${route.path}`,\n route.schema.description,\n route.schema.tags,\n );\n }\n\n for (const staticRoute of app.staticRoutes) {\n swaggerInstance.addRoute(\"GET\", staticRoute.path, {}, `Static route ${staticRoute.path}`);\n }\n\n for (const [path] of app.wsRoutes) {\n swaggerInstance.addRoute(\"WS\", path, {}, `WebSocket route ${path}`);\n }\n\n for (const [path, handlerData] of app.subscriptionHandlers) {\n swaggerInstance.addRoute(\n \"SUB\",\n path,\n {\n params: handlerData.schema.params,\n query: handlerData.schema.query,\n headers: handlerData.schema.headers,\n },\n handlerData.schema.description || `SUB ${path}`,\n handlerData.schema.description,\n handlerData.schema.tags,\n );\n }\n\n return swaggerApp;\n }\n\n return {\n plugin: createPlugin,\n swagger: swaggerInstance,\n };\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,QAAQ,UAA0B,EAAE,EAAE;CACpD,MAAM,kBAAkB,IAAIA,gBAAAA,QAAQ,QAAQ;CAE5C,MAAM,aAAa,IAAIC,SAAAA,UAAU,CAC9B,IAAI,WAAW;AACd,SAAO,IAAI,SAAS,gBAAgB,cAAc,EAAE,EAClD,SAAS,EAAE,gBAAgB,aAAa,EACzC,CAAC;GACF,CACD,IAAI,eAAe;AAClB,SAAO,gBAAgB,SAAS;GAChC;CAEJ,SAAS,aAAa,KAAyB;AAC7C,OAAK,MAAM,SAAS,IAAI,OACtB,iBAAgB,SACd,MAAM,QACN,MAAM,MACN;GACE,QAAQ,MAAM,OAAO;GACrB,OAAO,MAAM,OAAO;GACpB,MAAM,MAAM,OAAO;GACnB,UAAU,MAAM,OAAO;GACxB,EACD,MAAM,OAAO,eAAe,GAAG,MAAM,OAAO,GAAG,MAAM,QACrD,MAAM,OAAO,aACb,MAAM,OAAO,KACd;AAGH,OAAK,MAAM,eAAe,IAAI,aAC5B,iBAAgB,SAAS,OAAO,YAAY,MAAM,EAAE,EAAE,gBAAgB,YAAY,OAAO;AAG3F,OAAK,MAAM,CAAC,SAAS,IAAI,SACvB,iBAAgB,SAAS,MAAM,MAAM,EAAE,EAAE,mBAAmB,OAAO;AAGrE,OAAK,MAAM,CAAC,MAAM,gBAAgB,IAAI,qBACpC,iBAAgB,SACd,OACA,MACA;GACE,QAAQ,YAAY,OAAO;GAC3B,OAAO,YAAY,OAAO;GAC1B,SAAS,YAAY,OAAO;GAC7B,EACD,YAAY,OAAO,eAAe,OAAO,QACzC,YAAY,OAAO,aACnB,YAAY,OAAO,KACpB;AAGH,SAAO;;AAGT,QAAO;EACL,QAAQ;EACR,SAAS;EACV"}
@@ -0,0 +1,32 @@
1
+ import { Swagger, SwaggerOptions } from "./swagger.cjs";
2
+ import { Hedystia } from "hedystia";
3
+
4
+ //#region src/plugin.d.ts
5
+ /**
6
+ * Create Swagger plugin
7
+ * @param {SwaggerOptions} [options] - Swagger options
8
+ * @returns Plugin instance
9
+ */
10
+ declare function swagger(options?: SwaggerOptions): {
11
+ plugin: (app: Hedystia<any, any>) => Hedystia<[{
12
+ method: "GET";
13
+ path: "/";
14
+ params: any;
15
+ query: any;
16
+ headers: any;
17
+ response: any;
18
+ error: any;
19
+ }, {
20
+ method: "GET";
21
+ path: "/json";
22
+ params: any;
23
+ query: any;
24
+ headers: any;
25
+ response: any;
26
+ error: any;
27
+ }], {}, undefined>;
28
+ swagger: Swagger;
29
+ };
30
+ //#endregion
31
+ export { swagger };
32
+ //# sourceMappingURL=plugin.d.cts.map
@@ -0,0 +1,32 @@
1
+ import { Swagger, SwaggerOptions } from "./swagger.mjs";
2
+ import { Hedystia } from "hedystia";
3
+
4
+ //#region src/plugin.d.ts
5
+ /**
6
+ * Create Swagger plugin
7
+ * @param {SwaggerOptions} [options] - Swagger options
8
+ * @returns Plugin instance
9
+ */
10
+ declare function swagger(options?: SwaggerOptions): {
11
+ plugin: (app: Hedystia<any, any>) => Hedystia<[{
12
+ method: "GET";
13
+ path: "/";
14
+ params: any;
15
+ query: any;
16
+ headers: any;
17
+ response: any;
18
+ error: any;
19
+ }, {
20
+ method: "GET";
21
+ path: "/json";
22
+ params: any;
23
+ query: any;
24
+ headers: any;
25
+ response: any;
26
+ error: any;
27
+ }], {}, undefined>;
28
+ swagger: Swagger;
29
+ };
30
+ //#endregion
31
+ export { swagger };
32
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1,40 @@
1
+ import { Swagger } from "./swagger.mjs";
2
+ import { Hedystia } from "hedystia";
3
+ //#region src/plugin.ts
4
+ /**
5
+ * Create Swagger plugin
6
+ * @param {SwaggerOptions} [options] - Swagger options
7
+ * @returns Plugin instance
8
+ */
9
+ function swagger(options = {}) {
10
+ const swaggerInstance = new Swagger(options);
11
+ const swaggerApp = new Hedystia().get("/", () => {
12
+ return new Response(swaggerInstance.generateHTML(), { headers: { "Content-Type": "text/html" } });
13
+ }).get("/json", () => {
14
+ return swaggerInstance.getSpec();
15
+ });
16
+ function createPlugin(app) {
17
+ for (const route of app.routes) swaggerInstance.addRoute(route.method, route.path, {
18
+ params: route.schema.params,
19
+ query: route.schema.query,
20
+ body: route.schema.body,
21
+ response: route.schema.response
22
+ }, route.schema.description || `${route.method} ${route.path}`, route.schema.description, route.schema.tags);
23
+ for (const staticRoute of app.staticRoutes) swaggerInstance.addRoute("GET", staticRoute.path, {}, `Static route ${staticRoute.path}`);
24
+ for (const [path] of app.wsRoutes) swaggerInstance.addRoute("WS", path, {}, `WebSocket route ${path}`);
25
+ for (const [path, handlerData] of app.subscriptionHandlers) swaggerInstance.addRoute("SUB", path, {
26
+ params: handlerData.schema.params,
27
+ query: handlerData.schema.query,
28
+ headers: handlerData.schema.headers
29
+ }, handlerData.schema.description || `SUB ${path}`, handlerData.schema.description, handlerData.schema.tags);
30
+ return swaggerApp;
31
+ }
32
+ return {
33
+ plugin: createPlugin,
34
+ swagger: swaggerInstance
35
+ };
36
+ }
37
+ //#endregion
38
+ export { swagger };
39
+
40
+ //# sourceMappingURL=plugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { Hedystia } from \"hedystia\";\nimport { Swagger, type SwaggerOptions } from \"./swagger\";\n\n/**\n * Create Swagger plugin\n * @param {SwaggerOptions} [options] - Swagger options\n * @returns Plugin instance\n */\nexport function swagger(options: SwaggerOptions = {}) {\n const swaggerInstance = new Swagger(options);\n\n const swaggerApp = new Hedystia()\n .get(\"/\", () => {\n return new Response(swaggerInstance.generateHTML(), {\n headers: { \"Content-Type\": \"text/html\" },\n });\n })\n .get(\"/json\", () => {\n return swaggerInstance.getSpec();\n });\n\n function createPlugin(app: Hedystia<any, any>) {\n for (const route of app.routes) {\n swaggerInstance.addRoute(\n route.method,\n route.path,\n {\n params: route.schema.params,\n query: route.schema.query,\n body: route.schema.body,\n response: route.schema.response,\n },\n route.schema.description || `${route.method} ${route.path}`,\n route.schema.description,\n route.schema.tags,\n );\n }\n\n for (const staticRoute of app.staticRoutes) {\n swaggerInstance.addRoute(\"GET\", staticRoute.path, {}, `Static route ${staticRoute.path}`);\n }\n\n for (const [path] of app.wsRoutes) {\n swaggerInstance.addRoute(\"WS\", path, {}, `WebSocket route ${path}`);\n }\n\n for (const [path, handlerData] of app.subscriptionHandlers) {\n swaggerInstance.addRoute(\n \"SUB\",\n path,\n {\n params: handlerData.schema.params,\n query: handlerData.schema.query,\n headers: handlerData.schema.headers,\n },\n handlerData.schema.description || `SUB ${path}`,\n handlerData.schema.description,\n handlerData.schema.tags,\n );\n }\n\n return swaggerApp;\n }\n\n return {\n plugin: createPlugin,\n swagger: swaggerInstance,\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,QAAQ,UAA0B,EAAE,EAAE;CACpD,MAAM,kBAAkB,IAAI,QAAQ,QAAQ;CAE5C,MAAM,aAAa,IAAI,UAAU,CAC9B,IAAI,WAAW;AACd,SAAO,IAAI,SAAS,gBAAgB,cAAc,EAAE,EAClD,SAAS,EAAE,gBAAgB,aAAa,EACzC,CAAC;GACF,CACD,IAAI,eAAe;AAClB,SAAO,gBAAgB,SAAS;GAChC;CAEJ,SAAS,aAAa,KAAyB;AAC7C,OAAK,MAAM,SAAS,IAAI,OACtB,iBAAgB,SACd,MAAM,QACN,MAAM,MACN;GACE,QAAQ,MAAM,OAAO;GACrB,OAAO,MAAM,OAAO;GACpB,MAAM,MAAM,OAAO;GACnB,UAAU,MAAM,OAAO;GACxB,EACD,MAAM,OAAO,eAAe,GAAG,MAAM,OAAO,GAAG,MAAM,QACrD,MAAM,OAAO,aACb,MAAM,OAAO,KACd;AAGH,OAAK,MAAM,eAAe,IAAI,aAC5B,iBAAgB,SAAS,OAAO,YAAY,MAAM,EAAE,EAAE,gBAAgB,YAAY,OAAO;AAG3F,OAAK,MAAM,CAAC,SAAS,IAAI,SACvB,iBAAgB,SAAS,MAAM,MAAM,EAAE,EAAE,mBAAmB,OAAO;AAGrE,OAAK,MAAM,CAAC,MAAM,gBAAgB,IAAI,qBACpC,iBAAgB,SACd,OACA,MACA;GACE,QAAQ,YAAY,OAAO;GAC3B,OAAO,YAAY,OAAO;GAC1B,SAAS,YAAY,OAAO;GAC7B,EACD,YAAY,OAAO,eAAe,OAAO,QACzC,YAAY,OAAO,aACnB,YAAY,OAAO,KACpB;AAGH,SAAO;;AAGT,QAAO;EACL,QAAQ;EACR,SAAS;EACV"}