nicefox-graphdb 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/README.md +45 -35
  2. package/package.json +4 -2
package/README.md CHANGED
@@ -11,15 +11,33 @@ A lightweight graph database with Cypher query support, powered by SQLite.
11
11
  npm install nicefox-graphdb
12
12
  ```
13
13
 
14
+ ### Native Dependencies
15
+
16
+ The `better-sqlite3` native module is an **optional dependency**:
17
+
18
+ - **Production mode** (remote HTTP client): No native dependencies, no compilation required
19
+ - **Development mode** (local SQLite): Requires `better-sqlite3`
20
+
21
+ If you only connect to a remote GraphDB server, you can skip native compilation entirely:
22
+
23
+ ```bash
24
+ npm install nicefox-graphdb --ignore-optional
25
+ ```
26
+
27
+ For local/embedded mode, ensure `better-sqlite3` is installed:
28
+
29
+ ```bash
30
+ npm install nicefox-graphdb better-sqlite3
31
+ ```
32
+
14
33
  ## Quick Start
15
34
 
16
35
  ```typescript
17
36
  import { GraphDB } from 'nicefox-graphdb';
18
37
 
19
38
  const db = await GraphDB({
20
- url: 'https://my-graphdb.example.com',
21
- project: 'myapp',
22
- apiKey: process.env.GRAPHDB_API_KEY,
39
+ project: 'myapp', // or process.env.GRAPHDB_PROJECT
40
+ apiKey: 'nfx_xxx', // or process.env.GRAPHDB_API_KEY
23
41
  });
24
42
 
25
43
  // Create nodes and relationships
@@ -47,11 +65,7 @@ This means you can use the **exact same code** in both environments:
47
65
 
48
66
  ```typescript
49
67
  // Works in both development and production!
50
- const db = await GraphDB({
51
- url: 'https://my-graphdb.example.com',
52
- project: 'myapp',
53
- apiKey: process.env.GRAPHDB_API_KEY,
54
- });
68
+ const db = await GraphDB({ project: 'myapp' });
55
69
  ```
56
70
 
57
71
  ### Development Mode
@@ -82,38 +96,37 @@ NODE_ENV=production GRAPHDB_API_KEY=xxx node app.js
82
96
 
83
97
  | Option | Type | Required | Default | Description |
84
98
  |--------|------|----------|---------|-------------|
85
- | `url` | `string` | Yes | - | Base URL of the GraphDB server (used in production) |
86
- | `project` | `string` | Yes | - | Project name |
87
- | `apiKey` | `string` | No | - | API key for authentication (used in production) |
88
- | `env` | `'production' \| 'test'` | No | `'production'` | Environment (determines database isolation) |
89
- | `dataPath` | `string` | No | `'./data'` | Path for local data storage (development only). Use `':memory:'` for in-memory database |
99
+ | `url` | `string` | No | `GRAPHDB_URL` or `https://graphdb.nicefox.net` | Base URL of the GraphDB server (production only) |
100
+ | `project` | `string` | Yes | `GRAPHDB_PROJECT` | Project name |
101
+ | `apiKey` | `string` | No | `GRAPHDB_API_KEY` | API key for authentication (production only) |
102
+ | `env` | `string` | No | `NODE_ENV` or `production` | Environment (determines database isolation) |
103
+ | `dataPath` | `string` | No | `GRAPHDB_DATA_PATH` or `./data` | Path for local data storage (development only). Use `':memory:'` for in-memory database |
90
104
 
91
105
  ### Examples
92
106
 
107
+ **Production** (default when `NODE_ENV` is unset or `production`):
93
108
  ```typescript
94
- // Production: connect to remote server
95
109
  const db = await GraphDB({
96
- url: 'https://graphdb.example.com',
97
- project: 'myapp',
98
- apiKey: 'your-api-key',
99
- env: 'production',
110
+ project: 'myapp', // or process.env.GRAPHDB_PROJECT
111
+ apiKey: 'nfx_xxx', // or process.env.GRAPHDB_API_KEY
112
+ url: 'https://my-server', // or process.env.GRAPHDB_URL (default: graphdb.nicefox.net)
100
113
  });
114
+ ```
101
115
 
102
- // Development: use local SQLite (url/apiKey ignored)
103
- // NODE_ENV=development
116
+ **Development** (when `NODE_ENV=development`):
117
+ ```typescript
104
118
  const db = await GraphDB({
105
- url: 'https://graphdb.example.com', // ignored
106
- project: 'myapp',
107
- apiKey: 'your-api-key', // ignored
108
- dataPath: './local-data', // custom data directory
119
+ project: 'myapp', // or process.env.GRAPHDB_PROJECT
120
+ dataPath: './local-data', // or process.env.GRAPHDB_DATA_PATH (default: ./data)
109
121
  });
122
+ // url and apiKey are ignored - uses local SQLite
123
+ ```
110
124
 
111
- // Testing: use in-memory database
112
- // NODE_ENV=development
125
+ **Testing** (when `NODE_ENV=development`):
126
+ ```typescript
113
127
  const db = await GraphDB({
114
- url: 'https://graphdb.example.com',
115
128
  project: 'test-project',
116
- dataPath: ':memory:', // resets on each run
129
+ dataPath: ':memory:', // in-memory database, resets on each run
117
130
  });
118
131
  ```
119
132
 
@@ -305,15 +318,12 @@ npx nicefox-graphdb serve --port 3000 --host 0.0.0.0 --data ./data
305
318
  ### Creating Projects
306
319
 
307
320
  ```bash
308
- # Create a new project (generates API keys)
321
+ # Create a new project (generates API key)
309
322
  npx nicefox-graphdb create myapp --data ./data
310
323
 
311
324
  # Output:
312
325
  # [created] production/myapp.db
313
- # [created] test/myapp.db
314
- # API Keys:
315
- # production: nfx_abc123...
316
- # test: nfx_def456...
326
+ # API Key: nfx_abc123...
317
327
  ```
318
328
 
319
329
  ### CLI Reference
@@ -332,8 +342,8 @@ nicefox-graphdb delete <project> Delete project (use --force)
332
342
  nicefox-graphdb list List all projects
333
343
 
334
344
  # Environment management
335
- nicefox-graphdb clone <project> Copy production to test
336
- nicefox-graphdb wipe <project> Clear test database
345
+ nicefox-graphdb clone <project> --from <env> --to <env> Copy between environments
346
+ nicefox-graphdb wipe <project> --env <env> Clear environment database
337
347
 
338
348
  # Direct queries
339
349
  nicefox-graphdb query <env> <project> "CYPHER"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nicefox-graphdb",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "SQLite-based graph database with Cypher query support",
5
5
  "type": "module",
6
6
  "main": "packages/nicefox-graphdb/dist/index.js",
@@ -32,10 +32,12 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@hono/node-server": "^1.13.0",
35
- "better-sqlite3": "^11.0.0",
36
35
  "commander": "^12.0.0",
37
36
  "hono": "^4.0.0"
38
37
  },
38
+ "optionalDependencies": {
39
+ "better-sqlite3": "^11.0.0"
40
+ },
39
41
  "devDependencies": {
40
42
  "@types/better-sqlite3": "^7.6.0",
41
43
  "@types/node": "^22.0.0",