@singhak/nodeui-fastify 0.3.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/README.md +52 -0
- package/dist/index.cjs +87 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +62 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @singhak/nodeui-fastify
|
|
2
|
+
|
|
3
|
+
Fastify plugin adapter for the NodeUI developer console. Serves the bundled React
|
|
4
|
+
console and its API under `{path}` (default `/nodeui`), records app requests in
|
|
5
|
+
the request-log panel and lists your Fastify routes in the routes panel.
|
|
6
|
+
|
|
7
|
+
Supports Fastify 4 and 5.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @singhak/nodeui-fastify
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import Fastify from 'fastify';
|
|
19
|
+
import { nodeui } from '@singhak/nodeui-fastify';
|
|
20
|
+
|
|
21
|
+
const app = Fastify();
|
|
22
|
+
const ui = nodeui();
|
|
23
|
+
|
|
24
|
+
// Register before your routes so they appear in the routes panel.
|
|
25
|
+
await app.register(ui);
|
|
26
|
+
|
|
27
|
+
app.get('/hello', async () => ({ hello: 'world' }));
|
|
28
|
+
|
|
29
|
+
await app.listen({ port: 3000, host: '127.0.0.1' });
|
|
30
|
+
ui.server.mark('listening');
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Open `http://127.0.0.1:3000/nodeui` for the console and
|
|
34
|
+
`http://127.0.0.1:3000/nodeui/api/config` for the API.
|
|
35
|
+
|
|
36
|
+
The plugin is not encapsulated (equivalent to `fastify-plugin`), shuts the
|
|
37
|
+
server down on `app.close()`, and does nothing when NodeUI is disabled (for
|
|
38
|
+
example when `NODE_ENV=production`).
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
`nodeui(options?)` accepts any `@singhak/nodeui-core` `NodeUIOptions` (path, host
|
|
43
|
+
allow-lists, auth token, plugins, health checks, etc.). See the
|
|
44
|
+
`@singhak/nodeui-core` README for the full configuration table and safety model.
|
|
45
|
+
|
|
46
|
+
## Development
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run typecheck
|
|
50
|
+
npm test
|
|
51
|
+
npm run build
|
|
52
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
nodeui: () => nodeui
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_nodeui_core = require("@singhak/nodeui-core");
|
|
28
|
+
__reExport(index_exports, require("@singhak/nodeui-core"), module.exports);
|
|
29
|
+
function pathnameOf(url) {
|
|
30
|
+
try {
|
|
31
|
+
return new URL(url ?? "/", "http://localhost").pathname;
|
|
32
|
+
} catch {
|
|
33
|
+
return url ?? "/";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function nodeui(options) {
|
|
37
|
+
const server = (0, import_nodeui_core.createNodeUI)(options);
|
|
38
|
+
const prefix = server.config.path;
|
|
39
|
+
const isUnderPrefix = (p) => p === prefix || p.startsWith(`${prefix}/`);
|
|
40
|
+
const recorder = server.middleware();
|
|
41
|
+
const routes = /* @__PURE__ */ new Map();
|
|
42
|
+
const plugin = ((app, _opts, done) => {
|
|
43
|
+
if (!server.active) {
|
|
44
|
+
done();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
server.setRoutes(
|
|
48
|
+
() => [...routes.values()].sort(
|
|
49
|
+
(a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method)
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
app.addHook("onRoute", (route) => {
|
|
53
|
+
const methods = Array.isArray(route.method) ? route.method : [route.method];
|
|
54
|
+
const handler = route.handler?.name || "anonymous";
|
|
55
|
+
for (const m of methods) {
|
|
56
|
+
const method = String(m).toUpperCase();
|
|
57
|
+
if (isUnderPrefix(route.url)) continue;
|
|
58
|
+
routes.set(`${method} ${route.url}`, { method, path: route.url, handler });
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
app.addHook("onRequest", async (req, reply) => {
|
|
62
|
+
if (isUnderPrefix(pathnameOf(req.raw.url))) {
|
|
63
|
+
reply.hijack();
|
|
64
|
+
await server.handle(req.raw, reply.raw);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
recorder(req.raw, reply.raw, () => void 0);
|
|
68
|
+
});
|
|
69
|
+
app.addHook("onClose", (_instance, next) => {
|
|
70
|
+
server.shutdown();
|
|
71
|
+
next();
|
|
72
|
+
});
|
|
73
|
+
done();
|
|
74
|
+
});
|
|
75
|
+
const marks = plugin;
|
|
76
|
+
marks[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
77
|
+
marks[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "nodeui-fastify";
|
|
78
|
+
plugin.server = server;
|
|
79
|
+
plugin.addLogSource = server.addLogSource;
|
|
80
|
+
return plugin;
|
|
81
|
+
}
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
nodeui,
|
|
85
|
+
...require("@singhak/nodeui-core")
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { FastifyInstance, FastifyPluginCallback, RouteOptions } from 'fastify';\r\nimport {\r\n createNodeUI,\r\n type NodeUIOptions,\r\n type NodeUIServer,\r\n type RouteEntry,\r\n} from '@singhak/nodeui-core';\r\n\r\nexport interface NodeUIFastifyPlugin extends FastifyPluginCallback {\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\r\nfunction pathnameOf(url: string | undefined): string {\r\n try {\r\n return new URL(url ?? '/', 'http://localhost').pathname;\r\n } catch {\r\n return url ?? '/';\r\n }\r\n}\r\n\r\n/**\r\n * Creates the NodeUI Fastify plugin. Register it before your routes so the\r\n * routes panel and request log see them.\r\n *\r\n * @example\r\n * const ui = nodeui();\r\n * await app.register(ui);\r\n * await app.listen({ port: 3000, host: '127.0.0.1' });\r\n * ui.server.mark('listening');\r\n */\r\nexport function nodeui(options?: NodeUIOptions): NodeUIFastifyPlugin {\r\n const server = createNodeUI(options);\r\n const prefix = server.config.path;\r\n const isUnderPrefix = (p: string): boolean => p === prefix || p.startsWith(`${prefix}/`);\r\n const recorder = server.middleware();\r\n const routes = new Map<string, RouteEntry>();\r\n\r\n const plugin = ((app: FastifyInstance, _opts: unknown, done: (err?: Error) => void) => {\r\n if (!server.active) {\r\n done();\r\n return;\r\n }\r\n\r\n server.setRoutes(() =>\r\n [...routes.values()].sort(\r\n (a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method),\r\n ),\r\n );\r\n\r\n app.addHook('onRoute', (route: RouteOptions) => {\r\n const methods = Array.isArray(route.method) ? route.method : [route.method];\r\n const handler = (route.handler as { name?: string } | undefined)?.name || 'anonymous';\r\n for (const m of methods) {\r\n const method = String(m).toUpperCase();\r\n if (isUnderPrefix(route.url)) continue;\r\n routes.set(`${method} ${route.url}`, { method, path: route.url, handler });\r\n }\r\n });\r\n\r\n app.addHook('onRequest', async (req, reply) => {\r\n if (isUnderPrefix(pathnameOf(req.raw.url))) {\r\n reply.hijack();\r\n await server.handle(req.raw, reply.raw);\r\n return;\r\n }\r\n // Core's middleware records the request (finish listener) then calls next.\r\n recorder(req.raw, reply.raw, () => undefined);\r\n });\r\n\r\n app.addHook('onClose', (_instance, next) => {\r\n server.shutdown();\r\n next();\r\n });\r\n done();\r\n }) as NodeUIFastifyPlugin;\r\n\r\n // Same effect as fastify-plugin: expose hooks to the parent scope.\r\n const marks = plugin as unknown as Record<symbol, unknown>;\r\n marks[Symbol.for('skip-override')] = true;\r\n marks[Symbol.for('fastify.display-name')] = 'nodeui-fastify';\r\n plugin.server = server;\r\n plugin.addLogSource = server.addLogSource;\r\n return plugin;\r\n}\r\n\r\nexport * from '@singhak/nodeui-core';\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAKO;AAkFP,0BAAc,iCAxFd;AAeA,SAAS,WAAW,KAAiC;AACnD,MAAI;AACF,WAAO,IAAI,IAAI,OAAO,KAAK,kBAAkB,EAAE;AAAA,EACjD,QAAQ;AACN,WAAO,OAAO;AAAA,EAChB;AACF;AAYO,SAAS,OAAO,SAA8C;AACnE,QAAM,aAAS,iCAAa,OAAO;AACnC,QAAM,SAAS,OAAO,OAAO;AAC7B,QAAM,gBAAgB,CAAC,MAAuB,MAAM,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG;AACvF,QAAM,WAAW,OAAO,WAAW;AACnC,QAAM,SAAS,oBAAI,IAAwB;AAE3C,QAAM,UAAU,CAAC,KAAsB,OAAgB,SAAgC;AACrF,QAAI,CAAC,OAAO,QAAQ;AAClB,WAAK;AACL;AAAA,IACF;AAEA,WAAO;AAAA,MAAU,MACf,CAAC,GAAG,OAAO,OAAO,CAAC,EAAE;AAAA,QACnB,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,KAAK,EAAE,OAAO,cAAc,EAAE,MAAM;AAAA,MAC3E;AAAA,IACF;AAEA,QAAI,QAAQ,WAAW,CAAC,UAAwB;AAC9C,YAAM,UAAU,MAAM,QAAQ,MAAM,MAAM,IAAI,MAAM,SAAS,CAAC,MAAM,MAAM;AAC1E,YAAM,UAAW,MAAM,SAA2C,QAAQ;AAC1E,iBAAW,KAAK,SAAS;AACvB,cAAM,SAAS,OAAO,CAAC,EAAE,YAAY;AACrC,YAAI,cAAc,MAAM,GAAG,EAAG;AAC9B,eAAO,IAAI,GAAG,MAAM,IAAI,MAAM,GAAG,IAAI,EAAE,QAAQ,MAAM,MAAM,KAAK,QAAQ,CAAC;AAAA,MAC3E;AAAA,IACF,CAAC;AAED,QAAI,QAAQ,aAAa,OAAO,KAAK,UAAU;AAC7C,UAAI,cAAc,WAAW,IAAI,IAAI,GAAG,CAAC,GAAG;AAC1C,cAAM,OAAO;AACb,cAAM,OAAO,OAAO,IAAI,KAAK,MAAM,GAAG;AACtC;AAAA,MACF;AAEA,eAAS,IAAI,KAAK,MAAM,KAAK,MAAM,MAAS;AAAA,IAC9C,CAAC;AAED,QAAI,QAAQ,WAAW,CAAC,WAAW,SAAS;AAC1C,aAAO,SAAS;AAChB,WAAK;AAAA,IACP,CAAC;AACD,SAAK;AAAA,EACP;AAGA,QAAM,QAAQ;AACd,QAAM,uBAAO,IAAI,eAAe,CAAC,IAAI;AACrC,QAAM,uBAAO,IAAI,sBAAsB,CAAC,IAAI;AAC5C,SAAO,SAAS;AAChB,SAAO,eAAe,OAAO;AAC7B,SAAO;AACT;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FastifyPluginCallback } from 'fastify';
|
|
2
|
+
import { NodeUIServer, NodeUIOptions } from '@singhak/nodeui-core';
|
|
3
|
+
export * from '@singhak/nodeui-core';
|
|
4
|
+
|
|
5
|
+
interface NodeUIFastifyPlugin extends FastifyPluginCallback {
|
|
6
|
+
/** Handle to the underlying server (mark, shutdown, config). */
|
|
7
|
+
server: NodeUIServer;
|
|
8
|
+
/** Pushes an external log entry into the log viewer (logger adapter). */
|
|
9
|
+
addLogSource: NodeUIServer['addLogSource'];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates the NodeUI Fastify plugin. Register it before your routes so the
|
|
13
|
+
* routes panel and request log see them.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const ui = nodeui();
|
|
17
|
+
* await app.register(ui);
|
|
18
|
+
* await app.listen({ port: 3000, host: '127.0.0.1' });
|
|
19
|
+
* ui.server.mark('listening');
|
|
20
|
+
*/
|
|
21
|
+
declare function nodeui(options?: NodeUIOptions): NodeUIFastifyPlugin;
|
|
22
|
+
|
|
23
|
+
export { type NodeUIFastifyPlugin, nodeui };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FastifyPluginCallback } from 'fastify';
|
|
2
|
+
import { NodeUIServer, NodeUIOptions } from '@singhak/nodeui-core';
|
|
3
|
+
export * from '@singhak/nodeui-core';
|
|
4
|
+
|
|
5
|
+
interface NodeUIFastifyPlugin extends FastifyPluginCallback {
|
|
6
|
+
/** Handle to the underlying server (mark, shutdown, config). */
|
|
7
|
+
server: NodeUIServer;
|
|
8
|
+
/** Pushes an external log entry into the log viewer (logger adapter). */
|
|
9
|
+
addLogSource: NodeUIServer['addLogSource'];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates the NodeUI Fastify plugin. Register it before your routes so the
|
|
13
|
+
* routes panel and request log see them.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const ui = nodeui();
|
|
17
|
+
* await app.register(ui);
|
|
18
|
+
* await app.listen({ port: 3000, host: '127.0.0.1' });
|
|
19
|
+
* ui.server.mark('listening');
|
|
20
|
+
*/
|
|
21
|
+
declare function nodeui(options?: NodeUIOptions): NodeUIFastifyPlugin;
|
|
22
|
+
|
|
23
|
+
export { type NodeUIFastifyPlugin, nodeui };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
createNodeUI
|
|
4
|
+
} from "@singhak/nodeui-core";
|
|
5
|
+
export * from "@singhak/nodeui-core";
|
|
6
|
+
function pathnameOf(url) {
|
|
7
|
+
try {
|
|
8
|
+
return new URL(url ?? "/", "http://localhost").pathname;
|
|
9
|
+
} catch {
|
|
10
|
+
return url ?? "/";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function nodeui(options) {
|
|
14
|
+
const server = createNodeUI(options);
|
|
15
|
+
const prefix = server.config.path;
|
|
16
|
+
const isUnderPrefix = (p) => p === prefix || p.startsWith(`${prefix}/`);
|
|
17
|
+
const recorder = server.middleware();
|
|
18
|
+
const routes = /* @__PURE__ */ new Map();
|
|
19
|
+
const plugin = ((app, _opts, done) => {
|
|
20
|
+
if (!server.active) {
|
|
21
|
+
done();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
server.setRoutes(
|
|
25
|
+
() => [...routes.values()].sort(
|
|
26
|
+
(a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method)
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
app.addHook("onRoute", (route) => {
|
|
30
|
+
const methods = Array.isArray(route.method) ? route.method : [route.method];
|
|
31
|
+
const handler = route.handler?.name || "anonymous";
|
|
32
|
+
for (const m of methods) {
|
|
33
|
+
const method = String(m).toUpperCase();
|
|
34
|
+
if (isUnderPrefix(route.url)) continue;
|
|
35
|
+
routes.set(`${method} ${route.url}`, { method, path: route.url, handler });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
app.addHook("onRequest", async (req, reply) => {
|
|
39
|
+
if (isUnderPrefix(pathnameOf(req.raw.url))) {
|
|
40
|
+
reply.hijack();
|
|
41
|
+
await server.handle(req.raw, reply.raw);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
recorder(req.raw, reply.raw, () => void 0);
|
|
45
|
+
});
|
|
46
|
+
app.addHook("onClose", (_instance, next) => {
|
|
47
|
+
server.shutdown();
|
|
48
|
+
next();
|
|
49
|
+
});
|
|
50
|
+
done();
|
|
51
|
+
});
|
|
52
|
+
const marks = plugin;
|
|
53
|
+
marks[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
54
|
+
marks[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "nodeui-fastify";
|
|
55
|
+
plugin.server = server;
|
|
56
|
+
plugin.addLogSource = server.addLogSource;
|
|
57
|
+
return plugin;
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
nodeui
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { FastifyInstance, FastifyPluginCallback, RouteOptions } from 'fastify';\r\nimport {\r\n createNodeUI,\r\n type NodeUIOptions,\r\n type NodeUIServer,\r\n type RouteEntry,\r\n} from '@singhak/nodeui-core';\r\n\r\nexport interface NodeUIFastifyPlugin extends FastifyPluginCallback {\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\r\nfunction pathnameOf(url: string | undefined): string {\r\n try {\r\n return new URL(url ?? '/', 'http://localhost').pathname;\r\n } catch {\r\n return url ?? '/';\r\n }\r\n}\r\n\r\n/**\r\n * Creates the NodeUI Fastify plugin. Register it before your routes so the\r\n * routes panel and request log see them.\r\n *\r\n * @example\r\n * const ui = nodeui();\r\n * await app.register(ui);\r\n * await app.listen({ port: 3000, host: '127.0.0.1' });\r\n * ui.server.mark('listening');\r\n */\r\nexport function nodeui(options?: NodeUIOptions): NodeUIFastifyPlugin {\r\n const server = createNodeUI(options);\r\n const prefix = server.config.path;\r\n const isUnderPrefix = (p: string): boolean => p === prefix || p.startsWith(`${prefix}/`);\r\n const recorder = server.middleware();\r\n const routes = new Map<string, RouteEntry>();\r\n\r\n const plugin = ((app: FastifyInstance, _opts: unknown, done: (err?: Error) => void) => {\r\n if (!server.active) {\r\n done();\r\n return;\r\n }\r\n\r\n server.setRoutes(() =>\r\n [...routes.values()].sort(\r\n (a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method),\r\n ),\r\n );\r\n\r\n app.addHook('onRoute', (route: RouteOptions) => {\r\n const methods = Array.isArray(route.method) ? route.method : [route.method];\r\n const handler = (route.handler as { name?: string } | undefined)?.name || 'anonymous';\r\n for (const m of methods) {\r\n const method = String(m).toUpperCase();\r\n if (isUnderPrefix(route.url)) continue;\r\n routes.set(`${method} ${route.url}`, { method, path: route.url, handler });\r\n }\r\n });\r\n\r\n app.addHook('onRequest', async (req, reply) => {\r\n if (isUnderPrefix(pathnameOf(req.raw.url))) {\r\n reply.hijack();\r\n await server.handle(req.raw, reply.raw);\r\n return;\r\n }\r\n // Core's middleware records the request (finish listener) then calls next.\r\n recorder(req.raw, reply.raw, () => undefined);\r\n });\r\n\r\n app.addHook('onClose', (_instance, next) => {\r\n server.shutdown();\r\n next();\r\n });\r\n done();\r\n }) as NodeUIFastifyPlugin;\r\n\r\n // Same effect as fastify-plugin: expose hooks to the parent scope.\r\n const marks = plugin as unknown as Record<symbol, unknown>;\r\n marks[Symbol.for('skip-override')] = true;\r\n marks[Symbol.for('fastify.display-name')] = 'nodeui-fastify';\r\n plugin.server = server;\r\n plugin.addLogSource = server.addLogSource;\r\n return plugin;\r\n}\r\n\r\nexport * from '@singhak/nodeui-core';\r\n"],"mappings":";AACA;AAAA,EACE;AAAA,OAIK;AAkFP,cAAc;AAzEd,SAAS,WAAW,KAAiC;AACnD,MAAI;AACF,WAAO,IAAI,IAAI,OAAO,KAAK,kBAAkB,EAAE;AAAA,EACjD,QAAQ;AACN,WAAO,OAAO;AAAA,EAChB;AACF;AAYO,SAAS,OAAO,SAA8C;AACnE,QAAM,SAAS,aAAa,OAAO;AACnC,QAAM,SAAS,OAAO,OAAO;AAC7B,QAAM,gBAAgB,CAAC,MAAuB,MAAM,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG;AACvF,QAAM,WAAW,OAAO,WAAW;AACnC,QAAM,SAAS,oBAAI,IAAwB;AAE3C,QAAM,UAAU,CAAC,KAAsB,OAAgB,SAAgC;AACrF,QAAI,CAAC,OAAO,QAAQ;AAClB,WAAK;AACL;AAAA,IACF;AAEA,WAAO;AAAA,MAAU,MACf,CAAC,GAAG,OAAO,OAAO,CAAC,EAAE;AAAA,QACnB,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,KAAK,EAAE,OAAO,cAAc,EAAE,MAAM;AAAA,MAC3E;AAAA,IACF;AAEA,QAAI,QAAQ,WAAW,CAAC,UAAwB;AAC9C,YAAM,UAAU,MAAM,QAAQ,MAAM,MAAM,IAAI,MAAM,SAAS,CAAC,MAAM,MAAM;AAC1E,YAAM,UAAW,MAAM,SAA2C,QAAQ;AAC1E,iBAAW,KAAK,SAAS;AACvB,cAAM,SAAS,OAAO,CAAC,EAAE,YAAY;AACrC,YAAI,cAAc,MAAM,GAAG,EAAG;AAC9B,eAAO,IAAI,GAAG,MAAM,IAAI,MAAM,GAAG,IAAI,EAAE,QAAQ,MAAM,MAAM,KAAK,QAAQ,CAAC;AAAA,MAC3E;AAAA,IACF,CAAC;AAED,QAAI,QAAQ,aAAa,OAAO,KAAK,UAAU;AAC7C,UAAI,cAAc,WAAW,IAAI,IAAI,GAAG,CAAC,GAAG;AAC1C,cAAM,OAAO;AACb,cAAM,OAAO,OAAO,IAAI,KAAK,MAAM,GAAG;AACtC;AAAA,MACF;AAEA,eAAS,IAAI,KAAK,MAAM,KAAK,MAAM,MAAS;AAAA,IAC9C,CAAC;AAED,QAAI,QAAQ,WAAW,CAAC,WAAW,SAAS;AAC1C,aAAO,SAAS;AAChB,WAAK;AAAA,IACP,CAAC;AACD,SAAK;AAAA,EACP;AAGA,QAAM,QAAQ;AACd,QAAM,uBAAO,IAAI,eAAe,CAAC,IAAI;AACrC,QAAM,uBAAO,IAAI,sBAAsB,CAAC,IAAI;AAC5C,SAAO,SAAS;AAChB,SAAO,eAAe,OAAO;AAC7B,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@singhak/nodeui-fastify",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Fastify plugin adapter for the NodeUI developer console.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"keywords": [
|
|
22
|
+
"fastify",
|
|
23
|
+
"plugin",
|
|
24
|
+
"console",
|
|
25
|
+
"developer-tools",
|
|
26
|
+
"observability",
|
|
27
|
+
"debugging"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/Singhak/nodeui.git"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/Singhak/nodeui#readme",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/Singhak/nodeui/issues"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
47
|
+
"test": "vitest run"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@singhak/nodeui-core": "^0.3.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"fastify": "^4.0.0 || ^5.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.19.0",
|
|
57
|
+
"fastify": "^5.0.0",
|
|
58
|
+
"tsup": "^8.5.0",
|
|
59
|
+
"typescript": "^5.9.3",
|
|
60
|
+
"vitest": "^3.2.4"
|
|
61
|
+
},
|
|
62
|
+
"author": "Anil Kumar",
|
|
63
|
+
"type": "commonjs"
|
|
64
|
+
}
|