@x12i/static-memorix-explorer-api 1.3.1 → 1.3.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.
- package/README.md +28 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.js +42 -7
- package/guides/running-the-service.md +25 -10
- package/guides/using-the-api.md +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,6 +10,27 @@ See [guides/demo-app.md](./guides/demo-app.md) for the full walkthrough.
|
|
|
10
10
|
|
|
11
11
|
## Quick start
|
|
12
12
|
|
|
13
|
+
Install once, then run one command:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install --global @x12i/static-memorix-explorer-api
|
|
17
|
+
memorix-explorer
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Then open **http://localhost:5030/demo**. The command prints the Demo, API,
|
|
21
|
+
Health, and JSON paths when it starts. No database or additional configuration
|
|
22
|
+
is required.
|
|
23
|
+
|
|
24
|
+
Useful options:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
memorix-explorer --port 8080
|
|
28
|
+
memorix-explorer --help
|
|
29
|
+
memorix-explorer --version
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Run from this repository
|
|
33
|
+
|
|
13
34
|
```bash
|
|
14
35
|
npm install
|
|
15
36
|
npm run build
|
|
@@ -38,7 +59,7 @@ npx @x12i/static-memorix-explorer-api
|
|
|
38
59
|
Or, after a global install:
|
|
39
60
|
|
|
40
61
|
```bash
|
|
41
|
-
|
|
62
|
+
memorix-explorer
|
|
42
63
|
```
|
|
43
64
|
|
|
44
65
|
Override the port from the shell:
|
|
@@ -278,6 +299,12 @@ and `knowledgeId`.
|
|
|
278
299
|
|
|
279
300
|
## Release history
|
|
280
301
|
|
|
302
|
+
### v1.3.2
|
|
303
|
+
- Added the short `memorix-explorer` CLI command.
|
|
304
|
+
- Added `--help`/`-h` and `--version`/`-v` commands.
|
|
305
|
+
- Startup now prints clickable Demo, API, Health, and JSON locations.
|
|
306
|
+
- Reworked Quick Start documentation around install-once, run-one-command use.
|
|
307
|
+
|
|
281
308
|
### v1.3.1
|
|
282
309
|
- Rejected unsafe routing IDs, object types, and metadata keys before path use.
|
|
283
310
|
- Changed malformed and empty JSON handling from silent fallback to explicit
|
package/dist/server.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface StartServerOptions {
|
|
|
5
5
|
logger?: boolean;
|
|
6
6
|
installSignalHandlers?: boolean;
|
|
7
7
|
}
|
|
8
|
+
export declare const CLI_HELP = "Memorix Explorer static server\n\nUsage:\n memorix-explorer [options]\n\nOptions:\n --port <number> Port to listen on (default: 5030)\n --host <address> Host to bind (default: 0.0.0.0)\n -h, --help Show this help\n -v, --version Show the installed version\n\nEnvironment:\n MOCKS_DIR Writable JSON fixture directory\n MEMORIX_ORG_ID Organization routing ID\n MEMORIX_AGENT_ID Agent/Catalox routing ID\n\nExample:\n memorix-explorer --port 5030\n";
|
|
9
|
+
export declare function getPackageVersion(): string;
|
|
8
10
|
export declare function parseCliArgs(args: string[]): StartServerOptions;
|
|
9
11
|
export declare function isCliEntrypoint(argvPath: string | undefined, moduleUrl: string): boolean;
|
|
10
12
|
/** Build a loaded Fastify instance without opening a network port. */
|
package/dist/server.js
CHANGED
|
@@ -6,6 +6,29 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
import { store } from "./storage/InMemoryStore.js";
|
|
7
7
|
import { registerRoutes } from "./routes/index.js";
|
|
8
8
|
import { PORT, HOST, MOCKS_DIR } from "./config.js";
|
|
9
|
+
export const CLI_HELP = `Memorix Explorer static server
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
memorix-explorer [options]
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--port <number> Port to listen on (default: 5030)
|
|
16
|
+
--host <address> Host to bind (default: 0.0.0.0)
|
|
17
|
+
-h, --help Show this help
|
|
18
|
+
-v, --version Show the installed version
|
|
19
|
+
|
|
20
|
+
Environment:
|
|
21
|
+
MOCKS_DIR Writable JSON fixture directory
|
|
22
|
+
MEMORIX_ORG_ID Organization routing ID
|
|
23
|
+
MEMORIX_AGENT_ID Agent/Catalox routing ID
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
memorix-explorer --port 5030
|
|
27
|
+
`;
|
|
28
|
+
export function getPackageVersion() {
|
|
29
|
+
const packageFile = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../package.json");
|
|
30
|
+
return JSON.parse(fs.readFileSync(packageFile, "utf8")).version;
|
|
31
|
+
}
|
|
9
32
|
export function parseCliArgs(args) {
|
|
10
33
|
const options = {};
|
|
11
34
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -70,9 +93,13 @@ export async function startServer(options = {}) {
|
|
|
70
93
|
await app.listen({ port, host });
|
|
71
94
|
const address = app.server.address();
|
|
72
95
|
const boundPort = typeof address === "object" && address ? address.port : port;
|
|
96
|
+
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
73
97
|
// eslint-disable-next-line no-console
|
|
74
|
-
console.log(
|
|
75
|
-
console.log(`
|
|
98
|
+
console.log(`\nMemorix Explorer is ready`);
|
|
99
|
+
console.log(` Demo: http://${displayHost}:${boundPort}/demo`);
|
|
100
|
+
console.log(` API: http://${displayHost}:${boundPort}/api/explorer`);
|
|
101
|
+
console.log(` Health: http://${displayHost}:${boundPort}/health`);
|
|
102
|
+
console.log(` JSON: ${MOCKS_DIR}\n`);
|
|
76
103
|
if (options.installSignalHandlers ?? true) {
|
|
77
104
|
const shutdown = async () => {
|
|
78
105
|
console.log("\n[mock-memorix-explorer-api] flushing + shutting down");
|
|
@@ -87,9 +114,17 @@ export async function startServer(options = {}) {
|
|
|
87
114
|
}
|
|
88
115
|
const isCliEntry = isCliEntrypoint(process.argv[1], import.meta.url);
|
|
89
116
|
if (isCliEntry) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
console.
|
|
93
|
-
|
|
94
|
-
|
|
117
|
+
const args = process.argv.slice(2);
|
|
118
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
119
|
+
console.log(CLI_HELP);
|
|
120
|
+
}
|
|
121
|
+
else if (args.includes("--version") || args.includes("-v")) {
|
|
122
|
+
console.log(getPackageVersion());
|
|
123
|
+
}
|
|
124
|
+
else
|
|
125
|
+
Promise.resolve().then(() => startServer(parseCliArgs(args))).catch((err) => {
|
|
126
|
+
// eslint-disable-next-line no-console
|
|
127
|
+
console.error(err);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
});
|
|
95
130
|
}
|
|
@@ -12,9 +12,9 @@ from in-memory state backed by JSON files on disk.
|
|
|
12
12
|
npm install -g @x12i/static-memorix-explorer-api
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
This makes the `
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
This makes the short `memorix-explorer` command available globally.
|
|
16
|
+
`static-memorix-explorer-api` and `mock-memorix-explorer-api` remain available
|
|
17
|
+
as compatibility aliases.
|
|
18
18
|
|
|
19
19
|
### From source (git clone)
|
|
20
20
|
|
|
@@ -45,11 +45,19 @@ iteration, but not suitable for distribution.
|
|
|
45
45
|
### As a global CLI
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
|
|
48
|
+
memorix-explorer
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
After `npm install -g`, the CLI starts the server with default settings. The
|
|
52
|
-
mocks directory defaults to
|
|
52
|
+
mocks directory defaults to the bundled fixtures, and the CLI prints the URLs
|
|
53
|
+
to open:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
Memorix Explorer is ready
|
|
57
|
+
Demo: http://localhost:5030/demo
|
|
58
|
+
API: http://localhost:5030/api/explorer
|
|
59
|
+
Health: http://localhost:5030/health
|
|
60
|
+
```
|
|
53
61
|
|
|
54
62
|
### With `npx` (no global install)
|
|
55
63
|
|
|
@@ -61,8 +69,15 @@ Choose a port with a CLI option or environment variable. CLI options take
|
|
|
61
69
|
precedence:
|
|
62
70
|
|
|
63
71
|
```bash
|
|
64
|
-
|
|
65
|
-
PORT=5030 HOST=127.0.0.1
|
|
72
|
+
memorix-explorer --port 5030 --host 127.0.0.1
|
|
73
|
+
PORT=5030 HOST=127.0.0.1 memorix-explorer
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Built-in help and version output do not start the server:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
memorix-explorer --help
|
|
80
|
+
memorix-explorer --version
|
|
66
81
|
```
|
|
67
82
|
|
|
68
83
|
### From application code
|
|
@@ -111,7 +126,7 @@ containerized deployments, point it at a persistent application-owned volume
|
|
|
111
126
|
rather than relying on the package's bundled seed directory:
|
|
112
127
|
|
|
113
128
|
```bash
|
|
114
|
-
MOCKS_DIR=/var/lib/my-app/memorix-mocks
|
|
129
|
+
MOCKS_DIR=/var/lib/my-app/memorix-mocks memorix-explorer --port 5030
|
|
115
130
|
```
|
|
116
131
|
|
|
117
132
|
Configuration is resolved when the package is imported. In programmatic usage,
|
|
@@ -162,7 +177,7 @@ default.
|
|
|
162
177
|
Set to `true` or `1` to enable:
|
|
163
178
|
|
|
164
179
|
```bash
|
|
165
|
-
MEMORIX_EXPLORER_ENABLE_METADATA_WRITES=true
|
|
180
|
+
MEMORIX_EXPLORER_ENABLE_METADATA_WRITES=true memorix-explorer
|
|
166
181
|
```
|
|
167
182
|
|
|
168
183
|
### Disk flush
|
|
@@ -180,7 +195,7 @@ MOCKS_DIR=/path/to/my/fixtures \
|
|
|
180
195
|
MEMORIX_ORG_ID=neo \
|
|
181
196
|
MEMORIX_AGENT_ID=neo-agent \
|
|
182
197
|
MEMORIX_EXPLORER_ENABLE_METADATA_WRITES=true \
|
|
183
|
-
|
|
198
|
+
memorix-explorer
|
|
184
199
|
```
|
|
185
200
|
|
|
186
201
|
## Health checks
|
package/guides/using-the-api.md
CHANGED
|
@@ -261,5 +261,5 @@ when the corresponding feature flag is not enabled. Set the environment
|
|
|
261
261
|
variable to `true` or `1` to allow writes:
|
|
262
262
|
|
|
263
263
|
```bash
|
|
264
|
-
MEMORIX_EXPLORER_ENABLE_METADATA_WRITES=true
|
|
264
|
+
MEMORIX_EXPLORER_ENABLE_METADATA_WRITES=true memorix-explorer
|
|
265
265
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x12i/static-memorix-explorer-api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Static mock server providing full API parity for the Memorix Explorer API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/server.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"bin": {
|
|
18
|
+
"memorix-explorer": "dist/server.js",
|
|
18
19
|
"static-memorix-explorer-api": "dist/server.js",
|
|
19
20
|
"mock-memorix-explorer-api": "dist/server.js"
|
|
20
21
|
},
|