@singhak/nodeui-nestjs 0.3.0 → 0.3.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/README.md CHANGED
@@ -1,78 +1,78 @@
1
- # @singhak/nodeui-nestjs
2
-
3
- NestJS module adapter for the NodeUI developer console. Registers the core
4
- middleware for every route, serving the bundled React console and its API under
5
- `{path}` (default `/nodeui`) and recording app requests in the request-log
6
- panel.
7
-
8
- ## Install
9
-
10
- ```bash
11
- npm install @singhak/nodeui-nestjs
12
- ```
13
-
14
- Peer dependencies: `@nestjs/common`, `@nestjs/core`, `reflect-metadata`,
15
- `rxjs`.
16
-
17
- ## Usage
18
-
19
- ```ts
20
- import { Module } from '@nestjs/common';
21
- import { NodeUIModule } from '@singhak/nodeui-nestjs';
22
-
23
- @Module({ imports: [NodeUIModule.register()] })
24
- export class AppModule {}
25
- ```
26
-
27
- ```ts
28
- // main.ts
29
- import 'reflect-metadata';
30
- import { NestFactory } from '@nestjs/core';
31
- import { NodeUIService } from '@singhak/nodeui-nestjs';
32
- import { AppModule } from './app.module';
33
-
34
- async function bootstrap(): Promise<void> {
35
- const app = await NestFactory.create(AppModule);
36
- await app.listen(3000, '127.0.0.1');
37
- app.get(NodeUIService).mark('listening');
38
- }
39
-
40
- void bootstrap();
41
- ```
42
-
43
- Open `http://127.0.0.1:3000/nodeui` for the console and
44
- `http://127.0.0.1:3000/nodeui/api/config` for the API.
45
-
46
- ## NodeUIService
47
-
48
- Injectable handle to the underlying server:
49
-
50
- - `mark(name)` — record a startup timing mark.
51
- - `config` — the effective configuration.
52
- - `shutdown()` — stop all sampling and timers.
53
-
54
- ## Options
55
-
56
- `NodeUIModule.register(options?)` accepts any `@singhak/nodeui-core` `NodeUIOptions`.
57
- See the `@singhak/nodeui-core` README for the configuration table and safety model.
58
-
59
- ## Development
60
-
61
- ```bash
62
- npm run typecheck
63
- npm test
64
- npm run build
65
- ```
66
-
67
- ## Logs panel
68
-
69
- Nest's default logger writes to `process.stdout`, not `console.*`, so its output
70
- would not reach the Logs panel. Mirror it with `NodeUILogger`:
71
-
72
- ```ts
73
- const app = await NestFactory.create(AppModule, { bufferLogs: true });
74
- app.useLogger(app.get(NodeUILogger));
75
- ```
76
-
77
- The module also shuts the console down (stopping samplers and restoring
78
- `console.*`) when the Nest app closes.
1
+ # @singhak/nodeui-nestjs
2
+
3
+ NestJS module adapter for the NodeUI developer console. Registers the core
4
+ middleware for every route, serving the bundled React console and its API under
5
+ `{path}` (default `/nodeui`) and recording app requests in the request-log
6
+ panel.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @singhak/nodeui-nestjs
12
+ ```
13
+
14
+ Peer dependencies: `@nestjs/common`, `@nestjs/core`, `reflect-metadata`,
15
+ `rxjs`.
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { Module } from '@nestjs/common';
21
+ import { NodeUIModule } from '@singhak/nodeui-nestjs';
22
+
23
+ @Module({ imports: [NodeUIModule.register()] })
24
+ export class AppModule {}
25
+ ```
26
+
27
+ ```ts
28
+ // main.ts
29
+ import 'reflect-metadata';
30
+ import { NestFactory } from '@nestjs/core';
31
+ import { NodeUIService } from '@singhak/nodeui-nestjs';
32
+ import { AppModule } from './app.module';
33
+
34
+ async function bootstrap(): Promise<void> {
35
+ const app = await NestFactory.create(AppModule);
36
+ await app.listen(3000, '127.0.0.1');
37
+ app.get(NodeUIService).mark('listening');
38
+ }
39
+
40
+ void bootstrap();
41
+ ```
42
+
43
+ Open `http://127.0.0.1:3000/nodeui` for the console and
44
+ `http://127.0.0.1:3000/nodeui/api/config` for the API.
45
+
46
+ ## NodeUIService
47
+
48
+ Injectable handle to the underlying server:
49
+
50
+ - `mark(name)` — record a startup timing mark.
51
+ - `config` — the effective configuration.
52
+ - `shutdown()` — stop all sampling and timers.
53
+
54
+ ## Options
55
+
56
+ `NodeUIModule.register(options?)` accepts any `@singhak/nodeui-core` `NodeUIOptions`.
57
+ See the `@singhak/nodeui-core` README for the configuration table and safety model.
58
+
59
+ ## Development
60
+
61
+ ```bash
62
+ npm run typecheck
63
+ npm test
64
+ npm run build
65
+ ```
66
+
67
+ ## Logs panel
68
+
69
+ Nest's default logger writes to `process.stdout`, not `console.*`, so its output
70
+ would not reach the Logs panel. Mirror it with `NodeUILogger`:
71
+
72
+ ```ts
73
+ const app = await NestFactory.create(AppModule, { bufferLogs: true });
74
+ app.useLogger(app.get(NodeUILogger));
75
+ ```
76
+
77
+ The module also shuts the console down (stopping samplers and restoring
78
+ `console.*`) when the Nest app closes.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/nodeui.module.ts","../src/nodeui.logger.ts","../src/tokens.ts","../src/nodeui.service.ts"],"sourcesContent":["/**\r\n * @singhak/nodeui-nestjs — NestJS adapter for the NodeUI developer console.\r\n */\r\n\r\nexport { NodeUIModule } from './nodeui.module';\r\nexport { NodeUILogger } from './nodeui.logger';\r\nexport { NodeUIService } from './nodeui.service';\r\nexport { NODEUI_SERVER } from './tokens';\r\nexport * from '@singhak/nodeui-core';\r\n","import {\r\n DynamicModule,\r\n Inject,\r\n MiddlewareConsumer,\r\n Module,\r\n NestModule,\r\n OnModuleDestroy,\r\n} from '@nestjs/common';\r\nimport { createNodeUI, type NodeUIOptions, type NodeUIServer } from '@singhak/nodeui-core';\r\nimport { NodeUILogger } from './nodeui.logger';\r\nimport { NodeUIService } from './nodeui.service';\r\nimport { NODEUI_SERVER } from './tokens';\r\n\r\n/**\r\n * NestJS adapter for the NodeUI developer console. Mounts the core middleware\r\n * for every route; the console and its API live under `NODEUI_PATH` (default\r\n * `/nodeui`) and app requests are recorded in the request log.\r\n *\r\n * @example\r\n * @Module({ imports: [NodeUIModule.register()] })\r\n * export class AppModule {}\r\n */\r\n@Module({})\r\nexport class NodeUIModule implements NestModule, OnModuleDestroy {\r\n static register(options?: NodeUIOptions): DynamicModule {\r\n const server = createNodeUI(options);\r\n return {\r\n module: NodeUIModule,\r\n providers: [{ provide: NODEUI_SERVER, useValue: server }, NodeUIService, NodeUILogger],\r\n exports: [NodeUIService, NodeUILogger, NODEUI_SERVER],\r\n };\r\n }\r\n\r\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\r\n\r\n configure(consumer: MiddlewareConsumer): void {\r\n consumer.apply(this.server.middleware()).forRoutes('*');\r\n }\r\n\r\n /** Stops samplers and restores `console.*` when the Nest app closes. */\r\n onModuleDestroy(): void {\r\n this.server.shutdown();\r\n }\r\n}\r\n","import { ConsoleLogger, Inject, Injectable } from '@nestjs/common';\r\nimport type { NodeUIServer } from '@singhak/nodeui-core';\r\nimport { NODEUI_SERVER } from './tokens';\r\n\r\ntype Level = 'debug' | 'info' | 'warn' | 'error';\r\n\r\nfunction format(message: unknown, optionalParams: unknown[]): string {\r\n const parts = [\r\n message,\r\n ...optionalParams.filter((p) => typeof p === 'string' || p instanceof Error),\r\n ];\r\n return parts\r\n .map((p) =>\r\n typeof p === 'string' ? p : p instanceof Error ? (p.stack ?? p.message) : JSON.stringify(p),\r\n )\r\n .join(' ');\r\n}\r\n\r\n/**\r\n * Nest's default logger writes straight to `process.stdout`, bypassing\r\n * `console.*`, so the Logs panel would stay empty. Use this logger to mirror\r\n * every Nest log line into the panel while keeping the normal console output.\r\n *\r\n * @example\r\n * const app = await NestFactory.create(AppModule, { bufferLogs: true });\r\n * app.useLogger(app.get(NodeUILogger));\r\n */\r\n@Injectable()\r\nexport class NodeUILogger extends ConsoleLogger {\r\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {\r\n super();\r\n }\r\n\r\n private tee(level: Level, message: unknown, params: unknown[]): void {\r\n this.server.addLogSource({ level, message: format(message, params) });\r\n }\r\n\r\n override log(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('info', message, optionalParams);\r\n super.log(message, ...optionalParams);\r\n }\r\n\r\n override warn(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('warn', message, optionalParams);\r\n super.warn(message, ...optionalParams);\r\n }\r\n\r\n override error(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('error', message, optionalParams);\r\n super.error(message, ...optionalParams);\r\n }\r\n\r\n override debug(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('debug', message, optionalParams);\r\n super.debug(message, ...optionalParams);\r\n }\r\n\r\n override verbose(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('debug', message, optionalParams);\r\n super.verbose(message, ...optionalParams);\r\n }\r\n}\r\n","/** Injection token for the underlying NodeUIServer instance. */\nexport const NODEUI_SERVER = Symbol('NODEUI_SERVER');\n","import { Inject, Injectable } from '@nestjs/common';\nimport type { NodeUIServer } from '@singhak/nodeui-core';\nimport { NODEUI_SERVER } from './tokens';\n\n/** Injectable handle to the NodeUI server: record startup marks, read config. */\n@Injectable()\nexport class NodeUIService {\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\n\n mark(name: string): void {\n this.server.mark(name);\n }\n\n get config() {\n return this.server.config;\n }\n\n shutdown(): void {\n this.server.shutdown();\n }\n\n addLogSource(entry: { level: 'debug' | 'info' | 'warn' | 'error'; message: string }): void {\n this.server.addLogSource(entry);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAOO;AACP,yBAAoE;;;ACRpE,oBAAkD;;;ACC3C,IAAM,gBAAgB,uBAAO,eAAe;;;ADKnD,SAAS,OAAO,SAAkB,gBAAmC;AACnE,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,GAAG,eAAe,OAAO,CAAC,MAAM,OAAO,MAAM,YAAY,aAAa,KAAK;AAAA,EAC7E;AACA,SAAO,MACJ;AAAA,IAAI,CAAC,MACJ,OAAO,MAAM,WAAW,IAAI,aAAa,QAAS,EAAE,SAAS,EAAE,UAAW,KAAK,UAAU,CAAC;AAAA,EAC5F,EACC,KAAK,GAAG;AACb;AAYO,IAAM,eAAN,c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AChC;AACF;AAlBa,gBAAN;AAAA,MADN,2BAAW;AAAA,EAEG,8CAAO,aAAa;AAAA,GADtB;;;AHiBN,IAAM,eAAN,MAA0D;AAAA,EAU/D,YAAoD,QAAsB;AAAtB;AAAA,EAAuB;AAAA,EAAvB;AAAA,EATpD,OAAO,SAAS,SAAwC;AACtD,UAAM,aAAS,iCAAa,OAAO;AACnC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,WAAW,CAAC,EAAE,SAAS,eAAe,UAAU,OAAO,GAAG,eAAe,YAAY;AAAA,MACrF,SAAS,CAAC,eAAe,cAAc,aAAa;AAAA,IACtD;AAAA,EACF;AAAA,EAIA,UAAU,UAAoC;AAC5C,aAAS,MAAM,KAAK,OAAO,WAAW,CAAC,EAAE,UAAU,GAAG;AAAA,EACxD;AAAA;AAAA,EAGA,kBAAwB;AACtB,SAAK,OAAO,SAAS;AAAA,EACvB;AACF;AApBa,eAAN;AAAA,MADN,uBAAO,CAAC,CAAC;AAAA,EAWK,8CAAO,aAAa;AAAA,GAVtB;;;ADfb,0BAAc,iCARd;","names":["import_common","import_common"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/nodeui.module.ts","../src/nodeui.logger.ts","../src/tokens.ts","../src/nodeui.service.ts"],"sourcesContent":["/**\n * @singhak/nodeui-nestjs — NestJS adapter for the NodeUI developer console.\n */\n\nexport { NodeUIModule } from './nodeui.module';\nexport { NodeUILogger } from './nodeui.logger';\nexport { NodeUIService } from './nodeui.service';\nexport { NODEUI_SERVER } from './tokens';\nexport * from '@singhak/nodeui-core';\n","import {\n DynamicModule,\n Inject,\n MiddlewareConsumer,\n Module,\n NestModule,\n OnModuleDestroy,\n} from '@nestjs/common';\nimport { createNodeUI, type NodeUIOptions, type NodeUIServer } from '@singhak/nodeui-core';\nimport { NodeUILogger } from './nodeui.logger';\nimport { NodeUIService } from './nodeui.service';\nimport { NODEUI_SERVER } from './tokens';\n\n/**\n * NestJS adapter for the NodeUI developer console. Mounts the core middleware\n * for every route; the console and its API live under `NODEUI_PATH` (default\n * `/nodeui`) and app requests are recorded in the request log.\n *\n * @example\n * @Module({ imports: [NodeUIModule.register()] })\n * export class AppModule {}\n */\n@Module({})\nexport class NodeUIModule implements NestModule, OnModuleDestroy {\n static register(options?: NodeUIOptions): DynamicModule {\n const server = createNodeUI(options);\n return {\n module: NodeUIModule,\n providers: [{ provide: NODEUI_SERVER, useValue: server }, NodeUIService, NodeUILogger],\n exports: [NodeUIService, NodeUILogger, NODEUI_SERVER],\n };\n }\n\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\n\n configure(consumer: MiddlewareConsumer): void {\n consumer.apply(this.server.middleware()).forRoutes('*');\n }\n\n /** Stops samplers and restores `console.*` when the Nest app closes. */\n onModuleDestroy(): void {\n this.server.shutdown();\n }\n}\n","import { ConsoleLogger, Inject, Injectable } from '@nestjs/common';\nimport type { NodeUIServer } from '@singhak/nodeui-core';\nimport { NODEUI_SERVER } from './tokens';\n\ntype Level = 'debug' | 'info' | 'warn' | 'error';\n\nfunction format(message: unknown, optionalParams: unknown[]): string {\n const parts = [\n message,\n ...optionalParams.filter((p) => typeof p === 'string' || p instanceof Error),\n ];\n return parts\n .map((p) =>\n typeof p === 'string' ? p : p instanceof Error ? (p.stack ?? p.message) : JSON.stringify(p),\n )\n .join(' ');\n}\n\n/**\n * Nest's default logger writes straight to `process.stdout`, bypassing\n * `console.*`, so the Logs panel would stay empty. Use this logger to mirror\n * every Nest log line into the panel while keeping the normal console output.\n *\n * @example\n * const app = await NestFactory.create(AppModule, { bufferLogs: true });\n * app.useLogger(app.get(NodeUILogger));\n */\n@Injectable()\nexport class NodeUILogger extends ConsoleLogger {\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {\n super();\n }\n\n private tee(level: Level, message: unknown, params: unknown[]): void {\n this.server.addLogSource({ level, message: format(message, params) });\n }\n\n override log(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('info', message, optionalParams);\n super.log(message, ...optionalParams);\n }\n\n override warn(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('warn', message, optionalParams);\n super.warn(message, ...optionalParams);\n }\n\n override error(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('error', message, optionalParams);\n super.error(message, ...optionalParams);\n }\n\n override debug(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('debug', message, optionalParams);\n super.debug(message, ...optionalParams);\n }\n\n override verbose(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('debug', message, optionalParams);\n super.verbose(message, ...optionalParams);\n }\n}\n","/** Injection token for the underlying NodeUIServer instance. */\nexport const NODEUI_SERVER = Symbol('NODEUI_SERVER');\n","import { Inject, Injectable } from '@nestjs/common';\nimport type { NodeUIServer } from '@singhak/nodeui-core';\nimport { NODEUI_SERVER } from './tokens';\n\n/** Injectable handle to the NodeUI server: record startup marks, read config. */\n@Injectable()\nexport class NodeUIService {\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\n\n mark(name: string): void {\n this.server.mark(name);\n }\n\n get config() {\n return this.server.config;\n }\n\n shutdown(): void {\n this.server.shutdown();\n }\n\n addLogSource(entry: { level: 'debug' | 'info' | 'warn' | 'error'; message: string }): void {\n this.server.addLogSource(entry);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAOO;AACP,yBAAoE;;;ACRpE,oBAAkD;;;ACC3C,IAAM,gBAAgB,uBAAO,eAAe;;;ADKnD,SAAS,OAAO,SAAkB,gBAAmC;AACnE,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,GAAG,eAAe,OAAO,CAAC,MAAM,OAAO,MAAM,YAAY,aAAa,KAAK;AAAA,EAC7E;AACA,SAAO,MACJ;AAAA,IAAI,CAAC,MACJ,OAAO,MAAM,WAAW,IAAI,aAAa,QAAS,EAAE,SAAS,EAAE,UAAW,KAAK,UAAU,CAAC;AAAA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AAa,OAA8E;AACzF,SAAK,OAAO,aAAa,KAAK;AAAA,EAChC;AACF;AAlBa,gBAAN;AAAA,MADN,2BAAW;AAAA,EAEG,8CAAO,aAAa;AAAA,GADtB;;;AHiBN,IAAM,eAAN,MAA0D;AAAA,EAU/D,YAAoD,QAAsB;AAAtB;AAAA,EAAuB;AAAA,EAAvB;AAAA,EATpD,OAAO,SAAS,SAAwC;AACtD,UAAM,aAAS,iCAAa,OAAO;AACnC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,WAAW,CAAC,EAAE,SAAS,eAAe,UAAU,OAAO,GAAG,eAAe,YAAY;AAAA,MACrF,SAAS,CAAC,eAAe,cAAc,aAAa;AAAA,IACtD;AAAA,EACF;AAAA,EAIA,UAAU,UAAoC;AAC5C,aAAS,MAAM,KAAK,OAAO,WAAW,CAAC,EAAE,UAAU,GAAG;AAAA,EACxD;AAAA;AAAA,EAGA,kBAAwB;AACtB,SAAK,OAAO,SAAS;AAAA,EACvB;AACF;AApBa,eAAN;AAAA,MADN,uBAAO,CAAC,CAAC;AAAA,EAWK,8CAAO,aAAa;AAAA,GAVtB;;;ADfb,0BAAc,iCARd;","names":["import_common","import_common"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/nodeui.module.ts","../src/nodeui.logger.ts","../src/tokens.ts","../src/nodeui.service.ts","../src/index.ts"],"sourcesContent":["import {\r\n DynamicModule,\r\n Inject,\r\n MiddlewareConsumer,\r\n Module,\r\n NestModule,\r\n OnModuleDestroy,\r\n} from '@nestjs/common';\r\nimport { createNodeUI, type NodeUIOptions, type NodeUIServer } from '@singhak/nodeui-core';\r\nimport { NodeUILogger } from './nodeui.logger';\r\nimport { NodeUIService } from './nodeui.service';\r\nimport { NODEUI_SERVER } from './tokens';\r\n\r\n/**\r\n * NestJS adapter for the NodeUI developer console. Mounts the core middleware\r\n * for every route; the console and its API live under `NODEUI_PATH` (default\r\n * `/nodeui`) and app requests are recorded in the request log.\r\n *\r\n * @example\r\n * @Module({ imports: [NodeUIModule.register()] })\r\n * export class AppModule {}\r\n */\r\n@Module({})\r\nexport class NodeUIModule implements NestModule, OnModuleDestroy {\r\n static register(options?: NodeUIOptions): DynamicModule {\r\n const server = createNodeUI(options);\r\n return {\r\n module: NodeUIModule,\r\n providers: [{ provide: NODEUI_SERVER, useValue: server }, NodeUIService, NodeUILogger],\r\n exports: [NodeUIService, NodeUILogger, NODEUI_SERVER],\r\n };\r\n }\r\n\r\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\r\n\r\n configure(consumer: MiddlewareConsumer): void {\r\n consumer.apply(this.server.middleware()).forRoutes('*');\r\n }\r\n\r\n /** Stops samplers and restores `console.*` when the Nest app closes. */\r\n onModuleDestroy(): void {\r\n this.server.shutdown();\r\n }\r\n}\r\n","import { ConsoleLogger, Inject, Injectable } from '@nestjs/common';\r\nimport type { NodeUIServer } from '@singhak/nodeui-core';\r\nimport { NODEUI_SERVER } from './tokens';\r\n\r\ntype Level = 'debug' | 'info' | 'warn' | 'error';\r\n\r\nfunction format(message: unknown, optionalParams: unknown[]): string {\r\n const parts = [\r\n message,\r\n ...optionalParams.filter((p) => typeof p === 'string' || p instanceof Error),\r\n ];\r\n return parts\r\n .map((p) =>\r\n typeof p === 'string' ? p : p instanceof Error ? (p.stack ?? p.message) : JSON.stringify(p),\r\n )\r\n .join(' ');\r\n}\r\n\r\n/**\r\n * Nest's default logger writes straight to `process.stdout`, bypassing\r\n * `console.*`, so the Logs panel would stay empty. Use this logger to mirror\r\n * every Nest log line into the panel while keeping the normal console output.\r\n *\r\n * @example\r\n * const app = await NestFactory.create(AppModule, { bufferLogs: true });\r\n * app.useLogger(app.get(NodeUILogger));\r\n */\r\n@Injectable()\r\nexport class NodeUILogger extends ConsoleLogger {\r\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {\r\n super();\r\n }\r\n\r\n private tee(level: Level, message: unknown, params: unknown[]): void {\r\n this.server.addLogSource({ level, message: format(message, params) });\r\n }\r\n\r\n override log(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('info', message, optionalParams);\r\n super.log(message, ...optionalParams);\r\n }\r\n\r\n override warn(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('warn', message, optionalParams);\r\n super.warn(message, ...optionalParams);\r\n }\r\n\r\n override error(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('error', message, optionalParams);\r\n super.error(message, ...optionalParams);\r\n }\r\n\r\n override debug(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('debug', message, optionalParams);\r\n super.debug(message, ...optionalParams);\r\n }\r\n\r\n override verbose(message: unknown, ...optionalParams: unknown[]): void {\r\n this.tee('debug', message, optionalParams);\r\n super.verbose(message, ...optionalParams);\r\n }\r\n}\r\n","/** Injection token for the underlying NodeUIServer instance. */\nexport const NODEUI_SERVER = Symbol('NODEUI_SERVER');\n","import { Inject, Injectable } from '@nestjs/common';\nimport type { NodeUIServer } from '@singhak/nodeui-core';\nimport { NODEUI_SERVER } from './tokens';\n\n/** Injectable handle to the NodeUI server: record startup marks, read config. */\n@Injectable()\nexport class NodeUIService {\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\n\n mark(name: string): void {\n this.server.mark(name);\n }\n\n get config() {\n return this.server.config;\n }\n\n shutdown(): void {\n this.server.shutdown();\n }\n\n addLogSource(entry: { level: 'debug' | 'info' | 'warn' | 'error'; message: string }): void {\n this.server.addLogSource(entry);\n }\n}\n","/**\r\n * @singhak/nodeui-nestjs — NestJS adapter for the NodeUI developer console.\r\n */\r\n\r\nexport { NodeUIModule } from './nodeui.module';\r\nexport { NodeUILogger } from './nodeui.logger';\r\nexport { NodeUIService } from './nodeui.service';\r\nexport { NODEUI_SERVER } from './tokens';\r\nexport * from '@singhak/nodeui-core';\r\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA,EAEE,UAAAA;AAAA,EAEA;AAAA,OAGK;AACP,SAAS,oBAA2D;;;ACRpE,SAAS,eAAe,QAAQ,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AAA,GADtB;;;AE5Bb,SAAS,UAAAC,SAAQ,cAAAC,mBAAkB;AAM5B,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAAoD,QAAsB;AAAtB;AAAA,EAAuB;AAAA,EAAvB;AAAA,EAEpD,KAAK,MAAoB;AACvB,SAAK,OAAO,KAAK,IAAI;AAAA,EACvB;AAAA,EAEA,IAAI,SAAS;AACX,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,WAAiB;AACf,SAAK,OAAO,SAAS;AAAA,EACvB;AAAA,EAEA,aAAa,OAA8E;AACzF,SAAK,OAAO,aAAa,KAAK;AAAA,EAChC;AACF;AAlBa,gBAAN;AAAA,EADNC,YAAW;AAAA,EAEG,mBAAAC,QAAO,aAAa;AAAA,GADtB;;;AHiBN,IAAM,eAAN,MAA0D;AAAA,EAU/D,YAAoD,QAAsB;AAAtB;AAAA,EAAuB;AAAA,EAAvB;AAAA,EATpD,OAAO,SAAS,SAAwC;AACtD,UAAM,SAAS,aAAa,OAAO;AACnC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,WAAW,CAAC,EAAE,SAAS,eAAe,UAAU,OAAO,GAAG,eAAe,YAAY;AAAA,MACrF,SAAS,CAAC,eAAe,cAAc,aAAa;AAAA,IACtD;AAAA,EACF;AAAA,EAIA,UAAU,UAAoC;AAC5C,aAAS,MAAM,KAAK,OAAO,WAAW,CAAC,EAAE,UAAU,GAAG;AAAA,EACxD;AAAA;AAAA,EAGA,kBAAwB;AACtB,SAAK,OAAO,SAAS;AAAA,EACvB;AACF;AApBa,eAAN;AAAA,EADN,OAAO,CAAC,CAAC;AAAA,EAWK,mBAAAC,QAAO,aAAa;AAAA,GAVtB;;;AIfb,cAAc;","names":["Inject","Inject","Injectable","Injectable","Inject","Inject"]}
1
+ {"version":3,"sources":["../src/nodeui.module.ts","../src/nodeui.logger.ts","../src/tokens.ts","../src/nodeui.service.ts","../src/index.ts"],"sourcesContent":["import {\n DynamicModule,\n Inject,\n MiddlewareConsumer,\n Module,\n NestModule,\n OnModuleDestroy,\n} from '@nestjs/common';\nimport { createNodeUI, type NodeUIOptions, type NodeUIServer } from '@singhak/nodeui-core';\nimport { NodeUILogger } from './nodeui.logger';\nimport { NodeUIService } from './nodeui.service';\nimport { NODEUI_SERVER } from './tokens';\n\n/**\n * NestJS adapter for the NodeUI developer console. Mounts the core middleware\n * for every route; the console and its API live under `NODEUI_PATH` (default\n * `/nodeui`) and app requests are recorded in the request log.\n *\n * @example\n * @Module({ imports: [NodeUIModule.register()] })\n * export class AppModule {}\n */\n@Module({})\nexport class NodeUIModule implements NestModule, OnModuleDestroy {\n static register(options?: NodeUIOptions): DynamicModule {\n const server = createNodeUI(options);\n return {\n module: NodeUIModule,\n providers: [{ provide: NODEUI_SERVER, useValue: server }, NodeUIService, NodeUILogger],\n exports: [NodeUIService, NodeUILogger, NODEUI_SERVER],\n };\n }\n\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\n\n configure(consumer: MiddlewareConsumer): void {\n consumer.apply(this.server.middleware()).forRoutes('*');\n }\n\n /** Stops samplers and restores `console.*` when the Nest app closes. */\n onModuleDestroy(): void {\n this.server.shutdown();\n }\n}\n","import { ConsoleLogger, Inject, Injectable } from '@nestjs/common';\nimport type { NodeUIServer } from '@singhak/nodeui-core';\nimport { NODEUI_SERVER } from './tokens';\n\ntype Level = 'debug' | 'info' | 'warn' | 'error';\n\nfunction format(message: unknown, optionalParams: unknown[]): string {\n const parts = [\n message,\n ...optionalParams.filter((p) => typeof p === 'string' || p instanceof Error),\n ];\n return parts\n .map((p) =>\n typeof p === 'string' ? p : p instanceof Error ? (p.stack ?? p.message) : JSON.stringify(p),\n )\n .join(' ');\n}\n\n/**\n * Nest's default logger writes straight to `process.stdout`, bypassing\n * `console.*`, so the Logs panel would stay empty. Use this logger to mirror\n * every Nest log line into the panel while keeping the normal console output.\n *\n * @example\n * const app = await NestFactory.create(AppModule, { bufferLogs: true });\n * app.useLogger(app.get(NodeUILogger));\n */\n@Injectable()\nexport class NodeUILogger extends ConsoleLogger {\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {\n super();\n }\n\n private tee(level: Level, message: unknown, params: unknown[]): void {\n this.server.addLogSource({ level, message: format(message, params) });\n }\n\n override log(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('info', message, optionalParams);\n super.log(message, ...optionalParams);\n }\n\n override warn(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('warn', message, optionalParams);\n super.warn(message, ...optionalParams);\n }\n\n override error(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('error', message, optionalParams);\n super.error(message, ...optionalParams);\n }\n\n override debug(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('debug', message, optionalParams);\n super.debug(message, ...optionalParams);\n }\n\n override verbose(message: unknown, ...optionalParams: unknown[]): void {\n this.tee('debug', message, optionalParams);\n super.verbose(message, ...optionalParams);\n }\n}\n","/** Injection token for the underlying NodeUIServer instance. */\nexport const NODEUI_SERVER = Symbol('NODEUI_SERVER');\n","import { Inject, Injectable } from '@nestjs/common';\nimport type { NodeUIServer } from '@singhak/nodeui-core';\nimport { NODEUI_SERVER } from './tokens';\n\n/** Injectable handle to the NodeUI server: record startup marks, read config. */\n@Injectable()\nexport class NodeUIService {\n constructor(@Inject(NODEUI_SERVER) private readonly server: NodeUIServer) {}\n\n mark(name: string): void {\n this.server.mark(name);\n }\n\n get config() {\n return this.server.config;\n }\n\n shutdown(): void {\n this.server.shutdown();\n }\n\n addLogSource(entry: { level: 'debug' | 'info' | 'warn' | 'error'; message: string }): void {\n this.server.addLogSource(entry);\n }\n}\n","/**\n * @singhak/nodeui-nestjs — NestJS adapter for the NodeUI developer console.\n */\n\nexport { NodeUIModule } from './nodeui.module';\nexport { NodeUILogger } from './nodeui.logger';\nexport { NodeUIService } from './nodeui.service';\nexport { NODEUI_SERVER } from './tokens';\nexport * from '@singhak/nodeui-core';\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA,EAEE,UA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hak/nodeui-nestjs",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "NestJS module adapter for the NodeUI developer console.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.cjs",
@@ -47,7 +47,7 @@
47
47
  "test": "vitest run"
48
48
  },
49
49
  "dependencies": {
50
- "@singhak/nodeui-core": "^0.3.0"
50
+ "@singhak/nodeui-core": "^0.3.1"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@nestjs/common": "^11.0.0",