nestjs-wsgate 0.0.1
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 +1 -0
- package/README.md +1 -0
- package/dist/decorators/ws-doc.decorator.d.ts +66 -0
- package/dist/decorators/ws-doc.decorator.d.ts.map +1 -0
- package/dist/decorators/ws-doc.decorator.js +48 -0
- package/dist/decorators/ws-doc.decorator.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/index.html +197 -0
- package/dist/wsgate.explorer.d.ts +67 -0
- package/dist/wsgate.explorer.d.ts.map +1 -0
- package/dist/wsgate.explorer.js +117 -0
- package/dist/wsgate.explorer.js.map +1 -0
- package/dist/wsgate.module.d.ts +66 -0
- package/dist/wsgate.module.d.ts.map +1 -0
- package/dist/wsgate.module.js +94 -0
- package/dist/wsgate.module.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MIT License
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[Read Readme on github](https://github.com/shaishab316/nestjs-wsgate)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nestjs-wsgate
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 Shaishab Chandra Shil (@shaishab316)
|
|
5
|
+
* MIT License — https://opensource.org/licenses/MIT
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A unique metadata key for storing WebSocket event documentation
|
|
11
|
+
* on handler methods via `@WsDoc()`.
|
|
12
|
+
*
|
|
13
|
+
* @internal Do not change — this key is used internally by `WsgateExplorer`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const WSGATE_EVENT_METADATA = "wsgate:event_doc";
|
|
16
|
+
/**
|
|
17
|
+
* Options for the `@WsDoc()` decorator.
|
|
18
|
+
* Describes a WebSocket gateway event for the nestjs-wsgate UI.
|
|
19
|
+
*/
|
|
20
|
+
export interface WsDocOptions {
|
|
21
|
+
/** The name of the Socket.IO event this handler listens to (client → server). */
|
|
22
|
+
event: string;
|
|
23
|
+
/** A short human-readable description of what this event does. */
|
|
24
|
+
description?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The expected payload shape for this event.
|
|
27
|
+
* Keys are field names, values are their types (e.g. `{ roomId: 'string' }`).
|
|
28
|
+
*
|
|
29
|
+
* Supports:
|
|
30
|
+
* - Primitives: `'string'`, `'number'`, `'boolean'`
|
|
31
|
+
* - Enums: `'info | warn | error'` (pipe-separated)
|
|
32
|
+
*/
|
|
33
|
+
payload?: Record<string, string>;
|
|
34
|
+
/** The Socket.IO event name emitted back to the client (server → client). */
|
|
35
|
+
response?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether this event is emitted by the client or received from the server.
|
|
38
|
+
* - `emit` — client sends this event to the server (default)
|
|
39
|
+
* - `subscribe` — server sends this event to the client
|
|
40
|
+
*
|
|
41
|
+
* @default 'emit'
|
|
42
|
+
*/
|
|
43
|
+
type?: "emit" | "subscribe";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Marks a WebSocket gateway method as a documented event.
|
|
47
|
+
* Metadata is collected at bootstrap by `WsgateExplorer` and
|
|
48
|
+
* served via the nestjs-wsgate interactive UI.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Event documentation options. See {@link WsDocOptions}.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* @WsDoc({
|
|
55
|
+
* event: 'sendMessage',
|
|
56
|
+
* description: 'Send a message to a room',
|
|
57
|
+
* payload: { roomId: 'string', message: 'string' },
|
|
58
|
+
* response: 'receiveMessage',
|
|
59
|
+
* type: 'emit',
|
|
60
|
+
* })
|
|
61
|
+
* @SubscribeMessage('sendMessage')
|
|
62
|
+
* handleMessage(@MessageBody() dto: SendMessageDto) {}
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare const WsDoc: (options: WsDocOptions) => MethodDecorator;
|
|
66
|
+
//# sourceMappingURL=ws-doc.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-doc.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/ws-doc.decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAIxD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IAEd,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAC7B;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,YAAY,KAAG,eAK7C,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* nestjs-wsgate
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2026 Shaishab Chandra Shil (@shaishab316)
|
|
6
|
+
* MIT License — https://opensource.org/licenses/MIT
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.WsDoc = exports.WSGATE_EVENT_METADATA = void 0;
|
|
12
|
+
const common_1 = require("@nestjs/common");
|
|
13
|
+
// ── Metadata Key ──────────────────────────────────────
|
|
14
|
+
/**
|
|
15
|
+
* A unique metadata key for storing WebSocket event documentation
|
|
16
|
+
* on handler methods via `@WsDoc()`.
|
|
17
|
+
*
|
|
18
|
+
* @internal Do not change — this key is used internally by `WsgateExplorer`.
|
|
19
|
+
*/
|
|
20
|
+
exports.WSGATE_EVENT_METADATA = "wsgate:event_doc";
|
|
21
|
+
// ── Decorator ─────────────────────────────────────────
|
|
22
|
+
/**
|
|
23
|
+
* Marks a WebSocket gateway method as a documented event.
|
|
24
|
+
* Metadata is collected at bootstrap by `WsgateExplorer` and
|
|
25
|
+
* served via the nestjs-wsgate interactive UI.
|
|
26
|
+
*
|
|
27
|
+
* @param options - Event documentation options. See {@link WsDocOptions}.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* @WsDoc({
|
|
32
|
+
* event: 'sendMessage',
|
|
33
|
+
* description: 'Send a message to a room',
|
|
34
|
+
* payload: { roomId: 'string', message: 'string' },
|
|
35
|
+
* response: 'receiveMessage',
|
|
36
|
+
* type: 'emit',
|
|
37
|
+
* })
|
|
38
|
+
* @SubscribeMessage('sendMessage')
|
|
39
|
+
* handleMessage(@MessageBody() dto: SendMessageDto) {}
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
const WsDoc = (options) => {
|
|
43
|
+
// Apply defaults
|
|
44
|
+
options.type ?? (options.type = "emit");
|
|
45
|
+
return (0, common_1.SetMetadata)(exports.WSGATE_EVENT_METADATA, options);
|
|
46
|
+
};
|
|
47
|
+
exports.WsDoc = WsDoc;
|
|
48
|
+
//# sourceMappingURL=ws-doc.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-doc.decorator.js","sourceRoot":"","sources":["../../src/decorators/ws-doc.decorator.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,2CAA6C;AAE7C,yDAAyD;AAEzD;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,kBAAkB,CAAC;AAsCxD,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,KAAK,GAAG,CAAC,OAAqB,EAAmB,EAAE;IAC9D,iBAAiB;IACjB,OAAO,CAAC,IAAI,KAAZ,OAAO,CAAC,IAAI,GAAK,MAAM,EAAC;IAExB,OAAO,IAAA,oBAAW,EAAC,6BAAqB,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC,CAAC;AALW,QAAA,KAAK,SAKhB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nestjs-wsgate
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 Shaishab Chandra Shil (@shaishab316)
|
|
5
|
+
* MIT License — https://opensource.org/licenses/MIT
|
|
6
|
+
*
|
|
7
|
+
* An interactive WebSocket documentation UI for NestJS.
|
|
8
|
+
* Like Swagger UI, but for Socket.IO gateway events.
|
|
9
|
+
*
|
|
10
|
+
* GitHub : https://github.com/shaishab316/nestjs-wsgate
|
|
11
|
+
* npm : https://www.npmjs.com/package/nestjs-wsgate
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
export { WsgateModule } from "./wsgate.module";
|
|
16
|
+
export type { WsgateOptions } from "./wsgate.module";
|
|
17
|
+
export { WsgateExplorer } from "./wsgate.explorer";
|
|
18
|
+
export type { WsEventMeta } from "./wsgate.explorer";
|
|
19
|
+
export { WsDoc } from "./decorators/ws-doc.decorator";
|
|
20
|
+
export type { WsDocOptions } from "./decorators/ws-doc.decorator";
|
|
21
|
+
export { WSGATE_EVENT_METADATA } from "./decorators/ws-doc.decorator";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* nestjs-wsgate
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2026 Shaishab Chandra Shil (@shaishab316)
|
|
6
|
+
* MIT License — https://opensource.org/licenses/MIT
|
|
7
|
+
*
|
|
8
|
+
* An interactive WebSocket documentation UI for NestJS.
|
|
9
|
+
* Like Swagger UI, but for Socket.IO gateway events.
|
|
10
|
+
*
|
|
11
|
+
* GitHub : https://github.com/shaishab316/nestjs-wsgate
|
|
12
|
+
* npm : https://www.npmjs.com/package/nestjs-wsgate
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.WSGATE_EVENT_METADATA = exports.WsDoc = exports.WsgateExplorer = exports.WsgateModule = void 0;
|
|
18
|
+
// ── Core Module ───────────────────────────────────────
|
|
19
|
+
// Main entry point for setting up the wsgate UI in a NestJS application.
|
|
20
|
+
var wsgate_module_1 = require("./wsgate.module");
|
|
21
|
+
Object.defineProperty(exports, "WsgateModule", { enumerable: true, get: function () { return wsgate_module_1.WsgateModule; } });
|
|
22
|
+
// ── Explorer ──────────────────────────────────────────
|
|
23
|
+
// Scans NestJS providers and collects @WsDoc() metadata at bootstrap.
|
|
24
|
+
var wsgate_explorer_1 = require("./wsgate.explorer");
|
|
25
|
+
Object.defineProperty(exports, "WsgateExplorer", { enumerable: true, get: function () { return wsgate_explorer_1.WsgateExplorer; } });
|
|
26
|
+
// ── Decorator ─────────────────────────────────────────
|
|
27
|
+
// Applied to gateway methods to mark them as documented socket events.
|
|
28
|
+
var ws_doc_decorator_1 = require("./decorators/ws-doc.decorator");
|
|
29
|
+
Object.defineProperty(exports, "WsDoc", { enumerable: true, get: function () { return ws_doc_decorator_1.WsDoc; } });
|
|
30
|
+
var ws_doc_decorator_2 = require("./decorators/ws-doc.decorator");
|
|
31
|
+
Object.defineProperty(exports, "WSGATE_EVENT_METADATA", { enumerable: true, get: function () { return ws_doc_decorator_2.WSGATE_EVENT_METADATA; } });
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,yDAAyD;AACzD,yEAAyE;AACzE,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAGrB,yDAAyD;AACzD,sEAAsE;AACtE,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAGvB,yDAAyD;AACzD,uEAAuE;AACvE,kEAAsD;AAA7C,yGAAA,KAAK,OAAA;AAEd,kEAAsE;AAA7D,yHAAA,qBAAqB,OAAA"}
|
|
Binary file
|