@singhak/nodeui-express 0.3.1 → 0.5.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/dist/index.cjs +13 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +13 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,19 @@ var import_nodeui_core = require("@singhak/nodeui-core");
|
|
|
28
28
|
__reExport(index_exports, require("@singhak/nodeui-core"), module.exports);
|
|
29
29
|
function nodeui(options) {
|
|
30
30
|
const server = (0, import_nodeui_core.createNodeUI)(options);
|
|
31
|
-
|
|
31
|
+
const errorHandler = (err, req, res, next) => {
|
|
32
|
+
const route = req.route?.path;
|
|
33
|
+
server.recordError(err, {
|
|
34
|
+
route: typeof route === "string" ? `${req.baseUrl}${route}` : void 0
|
|
35
|
+
});
|
|
36
|
+
next(err);
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
middleware: server.middleware(),
|
|
40
|
+
server,
|
|
41
|
+
addLogSource: server.addLogSource,
|
|
42
|
+
errorHandler
|
|
43
|
+
};
|
|
32
44
|
}
|
|
33
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
46
|
0 && (module.exports = {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n createNodeUI,\n type NodeUIMiddleware,\n type NodeUIOptions,\n type NodeUIServer,\n} from '@singhak/nodeui-core';\n\nexport interface NodeUIExpress {\n /** Express middleware that mounts the console; call `app.use(middleware)`. */\n middleware: NodeUIMiddleware;\n /** Handle to the underlying server (mark, shutdown, config). */\n server: NodeUIServer;\n /** Pushes an external log entry into the log viewer (logger adapter). */\n addLogSource: NodeUIServer['addLogSource'];\n}\n\n/**\n * Creates the NodeUI Express middleware plus its server handle.\n *\n * @example\n * const { middleware, server } = nodeui();\n * app.use(middleware);\n * app.listen(3000, \"127.0.0.1\", () => server.mark(\"listening\"));\n */\nexport function nodeui(options?: NodeUIOptions): NodeUIExpress {\n const server = createNodeUI(options);\n return {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ErrorRequestHandler } from 'express';\r\nimport {\r\n createNodeUI,\r\n type NodeUIMiddleware,\r\n type NodeUIOptions,\r\n type NodeUIServer,\r\n} from '@singhak/nodeui-core';\r\n\r\nexport interface NodeUIExpress {\r\n /** Express middleware that mounts the console; call `app.use(middleware)`. */\r\n middleware: NodeUIMiddleware;\r\n /** Handle to the underlying server (mark, shutdown, config). */\r\n server: NodeUIServer;\r\n /** Pushes an external log entry into the log viewer (logger adapter). */\r\n addLogSource: NodeUIServer['addLogSource'];\r\n /**\r\n * Error-handling middleware that records the error in the Errors panel and\r\n * passes it on. Register it after your routes: `app.use(errorHandler)`.\r\n */\r\n errorHandler: ErrorRequestHandler;\r\n}\r\n\r\n/**\r\n * Creates the NodeUI Express middleware plus its server handle.\r\n *\r\n * @example\r\n * const { middleware, server } = nodeui();\r\n * app.use(middleware);\r\n * app.listen(3000, \"127.0.0.1\", () => server.mark(\"listening\"));\r\n */\r\nexport function nodeui(options?: NodeUIOptions): NodeUIExpress {\r\n const server = createNodeUI(options);\r\n const errorHandler: ErrorRequestHandler = (err, req, res, next) => {\r\n const route = (req as { route?: { path?: unknown } }).route?.path;\r\n server.recordError(err, {\r\n route: typeof route === 'string' ? `${req.baseUrl}${route}` : undefined,\r\n });\r\n next(err);\r\n };\r\n return {\r\n middleware: server.middleware(),\r\n server,\r\n addLogSource: server.addLogSource,\r\n errorHandler,\r\n };\r\n}\r\n\r\nexport * from '@singhak/nodeui-core';\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAKO;AAyCP,0BAAc,iCA/Cd;AA8BO,SAAS,OAAO,SAAwC;AAC7D,QAAM,aAAS,iCAAa,OAAO;AACnC,QAAM,eAAoC,CAAC,KAAK,KAAK,KAAK,SAAS;AACjE,UAAM,QAAS,IAAuC,OAAO;AAC7D,WAAO,YAAY,KAAK;AAAA,MACtB,OAAO,OAAO,UAAU,WAAW,GAAG,IAAI,OAAO,GAAG,KAAK,KAAK;AAAA,IAChE,CAAC;AACD,SAAK,GAAG;AAAA,EACV;AACA,SAAO;AAAA,IACL,YAAY,OAAO,WAAW;AAAA,IAC9B;AAAA,IACA,cAAc,OAAO;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorRequestHandler } from 'express';
|
|
1
2
|
import { NodeUIMiddleware, NodeUIServer, NodeUIOptions } from '@singhak/nodeui-core';
|
|
2
3
|
export * from '@singhak/nodeui-core';
|
|
3
4
|
|
|
@@ -8,6 +9,11 @@ interface NodeUIExpress {
|
|
|
8
9
|
server: NodeUIServer;
|
|
9
10
|
/** Pushes an external log entry into the log viewer (logger adapter). */
|
|
10
11
|
addLogSource: NodeUIServer['addLogSource'];
|
|
12
|
+
/**
|
|
13
|
+
* Error-handling middleware that records the error in the Errors panel and
|
|
14
|
+
* passes it on. Register it after your routes: `app.use(errorHandler)`.
|
|
15
|
+
*/
|
|
16
|
+
errorHandler: ErrorRequestHandler;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Creates the NodeUI Express middleware plus its server handle.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorRequestHandler } from 'express';
|
|
1
2
|
import { NodeUIMiddleware, NodeUIServer, NodeUIOptions } from '@singhak/nodeui-core';
|
|
2
3
|
export * from '@singhak/nodeui-core';
|
|
3
4
|
|
|
@@ -8,6 +9,11 @@ interface NodeUIExpress {
|
|
|
8
9
|
server: NodeUIServer;
|
|
9
10
|
/** Pushes an external log entry into the log viewer (logger adapter). */
|
|
10
11
|
addLogSource: NodeUIServer['addLogSource'];
|
|
12
|
+
/**
|
|
13
|
+
* Error-handling middleware that records the error in the Errors panel and
|
|
14
|
+
* passes it on. Register it after your routes: `app.use(errorHandler)`.
|
|
15
|
+
*/
|
|
16
|
+
errorHandler: ErrorRequestHandler;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Creates the NodeUI Express middleware plus its server handle.
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,19 @@ import {
|
|
|
5
5
|
export * from "@singhak/nodeui-core";
|
|
6
6
|
function nodeui(options) {
|
|
7
7
|
const server = createNodeUI(options);
|
|
8
|
-
|
|
8
|
+
const errorHandler = (err, req, res, next) => {
|
|
9
|
+
const route = req.route?.path;
|
|
10
|
+
server.recordError(err, {
|
|
11
|
+
route: typeof route === "string" ? `${req.baseUrl}${route}` : void 0
|
|
12
|
+
});
|
|
13
|
+
next(err);
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
middleware: server.middleware(),
|
|
17
|
+
server,
|
|
18
|
+
addLogSource: server.addLogSource,
|
|
19
|
+
errorHandler
|
|
20
|
+
};
|
|
9
21
|
}
|
|
10
22
|
export {
|
|
11
23
|
nodeui
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n createNodeUI,\n type NodeUIMiddleware,\n type NodeUIOptions,\n type NodeUIServer,\n} from '@singhak/nodeui-core';\n\nexport interface NodeUIExpress {\n /** Express middleware that mounts the console; call `app.use(middleware)`. */\n middleware: NodeUIMiddleware;\n /** Handle to the underlying server (mark, shutdown, config). */\n server: NodeUIServer;\n /** Pushes an external log entry into the log viewer (logger adapter). */\n addLogSource: NodeUIServer['addLogSource'];\n}\n\n/**\n * Creates the NodeUI Express middleware plus its server handle.\n *\n * @example\n * const { middleware, server } = nodeui();\n * app.use(middleware);\n * app.listen(3000, \"127.0.0.1\", () => server.mark(\"listening\"));\n */\nexport function nodeui(options?: NodeUIOptions): NodeUIExpress {\n const server = createNodeUI(options);\n return {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ErrorRequestHandler } from 'express';\r\nimport {\r\n createNodeUI,\r\n type NodeUIMiddleware,\r\n type NodeUIOptions,\r\n type NodeUIServer,\r\n} from '@singhak/nodeui-core';\r\n\r\nexport interface NodeUIExpress {\r\n /** Express middleware that mounts the console; call `app.use(middleware)`. */\r\n middleware: NodeUIMiddleware;\r\n /** Handle to the underlying server (mark, shutdown, config). */\r\n server: NodeUIServer;\r\n /** Pushes an external log entry into the log viewer (logger adapter). */\r\n addLogSource: NodeUIServer['addLogSource'];\r\n /**\r\n * Error-handling middleware that records the error in the Errors panel and\r\n * passes it on. Register it after your routes: `app.use(errorHandler)`.\r\n */\r\n errorHandler: ErrorRequestHandler;\r\n}\r\n\r\n/**\r\n * Creates the NodeUI Express middleware plus its server handle.\r\n *\r\n * @example\r\n * const { middleware, server } = nodeui();\r\n * app.use(middleware);\r\n * app.listen(3000, \"127.0.0.1\", () => server.mark(\"listening\"));\r\n */\r\nexport function nodeui(options?: NodeUIOptions): NodeUIExpress {\r\n const server = createNodeUI(options);\r\n const errorHandler: ErrorRequestHandler = (err, req, res, next) => {\r\n const route = (req as { route?: { path?: unknown } }).route?.path;\r\n server.recordError(err, {\r\n route: typeof route === 'string' ? `${req.baseUrl}${route}` : undefined,\r\n });\r\n next(err);\r\n };\r\n return {\r\n middleware: server.middleware(),\r\n server,\r\n addLogSource: server.addLogSource,\r\n errorHandler,\r\n };\r\n}\r\n\r\nexport * from '@singhak/nodeui-core';\r\n"],"mappings":";AACA;AAAA,EACE;AAAA,OAIK;AAyCP,cAAc;AAjBP,SAAS,OAAO,SAAwC;AAC7D,QAAM,SAAS,aAAa,OAAO;AACnC,QAAM,eAAoC,CAAC,KAAK,KAAK,KAAK,SAAS;AACjE,UAAM,QAAS,IAAuC,OAAO;AAC7D,WAAO,YAAY,KAAK;AAAA,MACtB,OAAO,OAAO,UAAU,WAAW,GAAG,IAAI,OAAO,GAAG,KAAK,KAAK;AAAA,IAChE,CAAC;AACD,SAAK,GAAG;AAAA,EACV;AACA,SAAO;AAAA,IACL,YAAY,OAAO,WAAW;AAAA,IAC9B;AAAA,IACA,cAAc,OAAO;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singhak/nodeui-express",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Express middleware 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.
|
|
50
|
+
"@singhak/nodeui-core": "^0.5.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"express": "^4.0.0 || ^5.0.0"
|