admindb 1.2.0 → 1.2.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 +226 -261
- package/dist/data/generator.d.ts +86 -0
- package/dist/data/generator.js +1031 -0
- package/dist/data/generator.js.map +1 -0
- package/dist/db/database.d.ts +4 -0
- package/dist/db/database.js +28 -1
- package/dist/db/database.js.map +1 -1
- package/dist/public/css/app.css +1 -1
- package/dist/public/css/input.css +9 -2
- package/dist/public/js/seed.js +377 -0
- package/dist/routes/api.js +62 -0
- package/dist/routes/api.js.map +1 -1
- package/dist/routes/databases.js.map +1 -1
- package/dist/routes/pages.js +24 -0
- package/dist/routes/pages.js.map +1 -1
- package/dist/views/pages/query.hbs +2 -2
- package/dist/views/pages/seed.hbs +86 -0
- package/dist/views/pages/table.hbs +5 -0
- package/dist/views/partials/navbar.hbs +1 -6
- package/dist/views/partials/sidebar.hbs +1 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,82 +1,101 @@
|
|
|
1
1
|
# AdminDB
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
[](https://www.npmjs.com/package/admindb)
|
|
5
4
|
[](LICENSE)
|
|
6
5
|
[](https://nodejs.org/)
|
|
7
|
-
[](https://github.com/MIbnEKhalid/admindb/actions/workflows/publish.yml)
|
|
8
6
|
[](https://www.npmjs.com/package/admindb)
|
|
7
|
+
[](https://github.com/MIbnEKhalid/admindb/actions/workflows/publish.yml)
|
|
9
8
|
|
|
9
|
+
**A browser-based SQLite administration tool.** Manage a SQLite database
|
|
10
|
+
entirely from the browser — browse and edit rows, run SQL, design schemas,
|
|
11
|
+
import/export and seed data — with no separate frontend app to build or deploy.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
- **No frontend build step.** Handlebars server-rendered UI + vanilla JS +
|
|
14
|
+
Tailwind/DaisyUI; one Express process serves pages, static assets, and the
|
|
15
|
+
JSON API.
|
|
16
|
+
- **Standalone or embeddable.** Run it from the CLI against a file or a folder
|
|
17
|
+
of databases, or mount it inside an existing Express app under any path on
|
|
18
|
+
the same port.
|
|
19
|
+
- **Safe SQL by construction.** Every identifier is quoted and every literal is
|
|
20
|
+
escaped when SQL is generated, and the "Get query / preview" modes only
|
|
21
|
+
produce SQL strings — they never execute.
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
- **Frontend:** Handlebars server-rendered templates, Tailwind CSS + DaisyUI,
|
|
20
|
-
plain JavaScript (no frontend framework).
|
|
21
|
-
- **Database:** SQLite via [better-sqlite3](https://github.com/WiseLibs/better-sqlite3). Requires
|
|
22
|
-
**Node.js ≥ 20**.
|
|
23
|
+

|
|
23
24
|
|
|
24
|
-
>
|
|
25
|
-
>
|
|
26
|
-
>
|
|
27
|
-
> Every page and API route (browse, edit, delete, run arbitrary SQL, change the
|
|
28
|
-
> schema, export the whole database, and — in manager mode — browse the
|
|
29
|
-
> filesystem to open database files) is available to **anyone who can reach the
|
|
30
|
-
> server**.
|
|
31
|
-
>
|
|
32
|
-
> - **No authentication or authorization is built in.** The routes are **not
|
|
33
|
-
> protected**.
|
|
34
|
-
> - **It is your responsibility to protect access.** Do **not** expose
|
|
35
|
-
> AdminDB to the public internet or to untrusted networks.
|
|
36
|
-
> - Recommended ways to protect it:
|
|
37
|
-
> - bind the standalone server to `127.0.0.1` (`HOST=127.0.0.1`) and use it
|
|
38
|
-
> only from your own machine, and/or
|
|
39
|
-
> - run it behind a reverse proxy that requires authentication (Basic auth,
|
|
40
|
-
> OAuth, mTLS, …) or inside a VPN / private network.
|
|
41
|
-
>
|
|
42
|
-
> Treat AdminDB as if it were a remote `sqlite3` shell with write access.
|
|
25
|
+
> More screenshots in [`docs/screenshots/`](docs/screenshots/): table browser,
|
|
26
|
+
> query editor, table designer, insert/edit form, schema editor, and the
|
|
27
|
+
> databases landing page.
|
|
43
28
|
|
|
44
|
-
|
|
29
|
+
## 30-Second Start
|
|
45
30
|
|
|
46
|
-
|
|
31
|
+
No install needed:
|
|
47
32
|
|
|
48
33
|
```bash
|
|
49
|
-
|
|
34
|
+
npx admindb
|
|
35
|
+
# → AdminDB is listening on http://localhost:3000
|
|
50
36
|
```
|
|
51
37
|
|
|
52
|
-
|
|
38
|
+
With no arguments the server starts in **manager mode**: a **Databases** landing
|
|
39
|
+
page where you can browse the filesystem and open any SQLite database file
|
|
40
|
+
(`.db` / `.sqlite` / `.sqlite3`), or create new ones. Or point it straight at a
|
|
41
|
+
file:
|
|
53
42
|
|
|
54
|
-
|
|
43
|
+
```bash
|
|
44
|
+
npx admindb ./data/app.db # open one database
|
|
45
|
+
npx admindb -d ./dbs # manage a folder of databases
|
|
46
|
+
```
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
`npx` — no install needed):
|
|
48
|
+
From a clone:
|
|
58
49
|
|
|
59
50
|
```bash
|
|
60
|
-
|
|
61
|
-
admindb
|
|
51
|
+
git clone https://github.com/MIbnEKhalid/admindb.git
|
|
52
|
+
cd admindb
|
|
53
|
+
npm install
|
|
54
|
+
npm run build
|
|
55
|
+
npm start # serves http://localhost:3000
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> Requires **Node.js ≥ 20**. Runtime dependencies are `express`,
|
|
59
|
+
> `express-handlebars`, and `better-sqlite3`; the rest is the application.
|
|
60
|
+
|
|
61
|
+
## Why This Exists
|
|
62
|
+
|
|
63
|
+
AdminDB exists because SQLite deserves a proper web admin UI, and desktop tools
|
|
64
|
+
(DBeaver, DB Browser for SQLite) live outside both your browser and your stack.
|
|
65
|
+
Web admin tools like phpMyAdmin target MySQL/Postgres, not SQLite. This one is
|
|
66
|
+
server-rendered, so there is no frontend build step and nothing extra to deploy
|
|
67
|
+
— the same Express process serves pages, assets, and the JSON API. Run it
|
|
68
|
+
standalone from the CLI, or mount it under any path of an existing Express app
|
|
69
|
+
on the same port.
|
|
70
|
+
|
|
71
|
+
## Install
|
|
72
|
+
|
|
73
|
+
### Try it (no install)
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx admindb -p 8080 # run on port 8080 without installing
|
|
77
|
+
npx admindb ./app.db # open a database file directly
|
|
62
78
|
```
|
|
63
79
|
|
|
64
|
-
|
|
80
|
+
### Install as a standalone CLI tool
|
|
81
|
+
|
|
82
|
+
Requires **Node.js ≥ 20**:
|
|
65
83
|
|
|
66
84
|
```bash
|
|
67
|
-
|
|
85
|
+
npm install -g admindb
|
|
86
|
+
admindb # starts the server → open http://localhost:3000
|
|
68
87
|
```
|
|
69
88
|
|
|
70
|
-
The `admindb` command starts the built-in server and
|
|
71
|
-
browser. See
|
|
72
|
-
|
|
89
|
+
The `admindb` command starts the built-in server and prints the URL to open in
|
|
90
|
+
your browser. See the [CLI reference](#cli-reference) for `--port`,
|
|
91
|
+
`--open <file>`, `--dir <folder>`, `--readonly`, and more.
|
|
73
92
|
|
|
74
|
-
|
|
93
|
+
### Embed AdminDB in your own app
|
|
75
94
|
|
|
76
|
-
AdminDB is an Express app you can mount inside your own application, under
|
|
77
|
-
|
|
95
|
+
AdminDB is an Express app you can mount inside your own application, under your
|
|
96
|
+
own path, on the same port as the rest of your server.
|
|
78
97
|
|
|
79
|
-
|
|
98
|
+
#### Minimal example
|
|
80
99
|
|
|
81
100
|
```ts
|
|
82
101
|
import express from 'express';
|
|
@@ -95,7 +114,7 @@ app.listen(3000);
|
|
|
95
114
|
`createRouter(options)` returns a fully wired Express app (pages + JSON API +
|
|
96
115
|
static assets + view engine). Mounting it is just `app.use('/path', router)`.
|
|
97
116
|
|
|
98
|
-
|
|
117
|
+
#### Options
|
|
99
118
|
|
|
100
119
|
| Option | Type | Description |
|
|
101
120
|
| ---------- | -------------------- | -------------------------------------------------------------- |
|
|
@@ -124,7 +143,7 @@ app.use('/tools/db', createRouter({
|
|
|
124
143
|
app.listen(3000);
|
|
125
144
|
```
|
|
126
145
|
|
|
127
|
-
|
|
146
|
+
#### Multiple databases
|
|
128
147
|
|
|
129
148
|
Pass a `DbManager` to manage several database files — either from a directory,
|
|
130
149
|
from an explicit list of file paths, or both:
|
|
@@ -137,9 +156,9 @@ const app = express();
|
|
|
137
156
|
app.use('/admin', createRouter({
|
|
138
157
|
manager: new DbManager(
|
|
139
158
|
{
|
|
140
|
-
dir: './data',
|
|
159
|
+
dir: './data', // scan a directory
|
|
141
160
|
files: ['/srv/legacy/app.db', './shared.sqlite'], // and/or explicit paths
|
|
142
|
-
readonly: true,
|
|
161
|
+
readonly: true, // open all databases read-only
|
|
143
162
|
},
|
|
144
163
|
createLogger('info'),
|
|
145
164
|
),
|
|
@@ -154,97 +173,13 @@ In multi-db mode:
|
|
|
154
173
|
`/admin/app.db/tables/users` and `/admin/app.db/api/tables`,
|
|
155
174
|
- file names that collide across sources are deduped (`name__2.db`).
|
|
156
175
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
- Browse every table and its rows (paginated, with primary-key awareness).
|
|
160
|
-
- **Filter rows by column** — type-aware, per-column filter controls: foreign-key
|
|
161
|
-
dropdowns, boolean toggles, date and numeric range inputs, plus the exact
|
|
162
|
-
(`=value`), comparison (`>5`, `<=10`), prefix (`pre*`) and substring (plain
|
|
163
|
-
text) operators on text columns. Filters survive sorting and pagination.
|
|
164
|
-
- **Inline (spreadsheet-style) editing** — double-click any cell to edit it in
|
|
165
|
-
place with a type-aware control (FK dropdown, boolean toggle, date picker,
|
|
166
|
-
number/text input). Changes are staged and highlighted in the grid, then
|
|
167
|
-
applied all at once in a single transaction, or discarded.
|
|
168
|
-
- Insert and delete rows (full CRUD). FK columns become dropdowns.
|
|
169
|
-
- **Bulk row operations** — select rows with checkboxes (or "select all"), then
|
|
170
|
-
**delete** them in one transaction (with a warning listing how many rows in
|
|
171
|
-
other tables reference them) or **export** only the selected rows as CSV/JSON.
|
|
172
|
-
- **Export** table rows or query results as **CSV or JSON**, and **import a CSV
|
|
173
|
-
file** (or pasted CSV) into a table.
|
|
174
|
-
- Create tables visually: name, type, primary key, not-null / unique,
|
|
175
|
-
default value, and foreign-key references.
|
|
176
|
-
- Write and run arbitrary SQL — SELECTs render as a table, `COUNT` queries show
|
|
177
|
-
a readable summary, write statements execute and report affected rows.
|
|
178
|
-
- Save named queries and reload them from a dropdown.
|
|
179
|
-
- Export the whole database as a downloadable SQL dump (`CREATE` + `INSERT`).
|
|
180
|
-
- **Get query / preview mode:** generate `CREATE` / `INSERT` / `UPDATE` SQL from
|
|
181
|
-
the UI without executing it.
|
|
182
|
-
- **Edit schema:** rename the table, add / rename / drop columns (with
|
|
183
|
-
relationship-safety checks), and drop tables.
|
|
184
|
-
- **Indexes:** create indexes (plain or unique, on one or many columns — pick
|
|
185
|
-
columns in order, with a live `CREATE INDEX` SQL preview) and drop them from
|
|
186
|
-
the schema editor; automatic SQLite indexes are protected.
|
|
187
|
-
- **Related rows:** every table that has a foreign key pointing at a table gets
|
|
188
|
-
its own column at the end of that table's grid — each cell shows how many of
|
|
189
|
-
its rows reference that record; click it to open a nested table with all of
|
|
190
|
-
the referencing table's columns and data for that specific record.
|
|
191
|
-
- **Read-only mode:** open the database(s) without write access — the file is
|
|
192
|
-
opened `SQLITE_OPEN_READONLY` + `query_only`, every write route returns `403`,
|
|
193
|
-
and the UI hides/disables all write controls and shows a banner.
|
|
194
|
-
- **Standalone CLI / file browser:** `admindb` runs as a full web app — with no
|
|
195
|
-
arguments it opens a **Databases** landing page where you can browse the
|
|
196
|
-
filesystem and open any SQLite database file, or create new ones. Flags set
|
|
197
|
-
the port, open a file, manage a folder, and more (`admindb --help`).
|
|
198
|
-
- **Multiple databases:** directory scanning and/or explicit file lists, each
|
|
199
|
-
with its own workspace under `/{db}/…`.
|
|
200
|
-
|
|
201
|
-
## Screenshots
|
|
202
|
-
|
|
203
|
-
Home dashboard — stat cards and the table list.
|
|
204
|
-
|
|
205
|
-

|
|
206
|
-
|
|
207
|
-
Table browser — sortable columns, sticky header, and per-row actions.
|
|
208
|
-
|
|
209
|
-

|
|
210
|
-
|
|
211
|
-
Query editor — line-numbered editor with a results table.
|
|
212
|
-
|
|
213
|
-

|
|
214
|
-
|
|
215
|
-
Table designer — visual columns with a live SQL preview.
|
|
216
|
-
|
|
217
|
-

|
|
176
|
+
### CLI reference
|
|
218
177
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-

|
|
222
|
-
|
|
223
|
-
Schema editor — rename the table, add / rename / drop columns safely.
|
|
224
|
-
|
|
225
|
-

|
|
226
|
-
|
|
227
|
-
Databases landing page (multi-db mode) — manage multiple SQLite files.
|
|
228
|
-
|
|
229
|
-

|
|
230
|
-
|
|
231
|
-
## Run the built-in server
|
|
232
|
-
|
|
233
|
-
For convenience a standalone server is included. From a clone of the repo:
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
npm install
|
|
237
|
-
npm run build
|
|
238
|
-
npm start # open http://localhost:3000
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
The server is a full standalone web app. With no arguments it runs in
|
|
178
|
+
The standalone server is a full web app. With no arguments it runs in
|
|
242
179
|
**manager mode**: a **Databases** landing page where you can browse the
|
|
243
180
|
filesystem and open any SQLite database file (`.db` / `.sqlite` / `.sqlite3`),
|
|
244
181
|
or create new ones.
|
|
245
182
|
|
|
246
|
-
### CLI flags
|
|
247
|
-
|
|
248
183
|
| Flag | Description |
|
|
249
184
|
| -------------------- | -------------------------------------------------------- |
|
|
250
185
|
| `-p, --port <port>` | Port to listen on (default `3000`) |
|
|
@@ -255,11 +190,14 @@ or create new ones.
|
|
|
255
190
|
| `-b, --base-path <p>`| URL prefix to serve under (default `/`) |
|
|
256
191
|
| `-r, --readonly` | Open databases read-only (all writes disabled) |
|
|
257
192
|
| `-l, --log-level <l>`| `debug` \| `info` \| `warn` \| `error` (default `info`) |
|
|
258
|
-
| `-h, --help` | Show help
|
|
193
|
+
| `-h, --help` | Show help |
|
|
259
194
|
| `-v, --version` | Show the version |
|
|
260
195
|
|
|
261
196
|
A positional `path` argument opens a database file directly, or manages a
|
|
262
|
-
folder when it is a directory.
|
|
197
|
+
folder when it is a directory.
|
|
198
|
+
|
|
199
|
+
Every flag has a matching environment variable; **flags override the
|
|
200
|
+
environment**:
|
|
263
201
|
|
|
264
202
|
| Variable | Default | Description |
|
|
265
203
|
| ----------- | ------- | ------------------------------------ |
|
|
@@ -293,7 +231,8 @@ page lists the managed databases and includes an **"Open an existing
|
|
|
293
231
|
database"** file browser: navigate folders, pick a database file, and open it.
|
|
294
232
|
Opened files are added to the list so you can switch between databases freely.
|
|
295
233
|
|
|
296
|
-
File-browser policy
|
|
234
|
+
**File-browser policy:**
|
|
235
|
+
|
|
297
236
|
- When a **folder** is given (`--dir`, a directory path, or `DB_DIR`), browsing
|
|
298
237
|
is limited to that folder — it cannot navigate above it and only databases
|
|
299
238
|
inside it can be opened.
|
|
@@ -302,135 +241,161 @@ File-browser policy:
|
|
|
302
241
|
listed.
|
|
303
242
|
- With no folder or files, browsing is unrestricted.
|
|
304
243
|
|
|
305
|
-
##
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
244
|
+
## Features
|
|
245
|
+
|
|
246
|
+
### 🔍 Browse & edit rows
|
|
247
|
+
|
|
248
|
+
- **Table browser** — every table with pagination, sorting (click a column
|
|
249
|
+
header), a sticky header, and per-row actions; composite primary keys are
|
|
250
|
+
supported (values are URL-encoded and comma-joined in the row endpoints).
|
|
251
|
+
- **Type-aware filters** — per-column filter controls: foreign-key dropdowns,
|
|
252
|
+
boolean toggles, date and numeric range inputs, plus the exact (`=value`),
|
|
253
|
+
comparison (`>5`, `<=10`), prefix (`pre*`) and substring (plain text)
|
|
254
|
+
operators on text columns. Filters survive sorting and pagination.
|
|
255
|
+
- **Inline (spreadsheet-style) editing** — double-click any cell to edit it in
|
|
256
|
+
place with a type-aware control (FK dropdown, boolean toggle, date picker,
|
|
257
|
+
number/text input). Changes are staged and highlighted in the grid, then
|
|
258
|
+
applied all at once in a single transaction, or discarded.
|
|
259
|
+
- **Insert and delete rows** (full CRUD). FK columns become dropdowns; insert
|
|
260
|
+
forms pre-fill column defaults from the schema.
|
|
261
|
+
- **Bulk row operations** — select rows with checkboxes (or "select all"), then
|
|
262
|
+
**delete** them in one transaction (with a warning listing how many rows in
|
|
263
|
+
other tables reference them) or **export** only the selected rows as CSV/JSON.
|
|
264
|
+
- **Related rows** — every table that has a foreign key pointing at a table gets
|
|
265
|
+
its own column at the end of that table's grid; each cell shows how many of its
|
|
266
|
+
rows reference that record. Click it to open a nested table with all of the
|
|
267
|
+
referencing table's columns and data for that specific record.
|
|
268
|
+
|
|
269
|
+
### ⚡ Query & run SQL
|
|
270
|
+
|
|
271
|
+
- **Arbitrary SQL runner** — SELECTs render as a table, `COUNT` queries show a
|
|
272
|
+
readable summary, and write statements execute and report affected rows.
|
|
273
|
+
- **Saved named queries** — save a query and reload it from a dropdown.
|
|
274
|
+
- **"Get query" / preview mode** — generate `CREATE` / `INSERT` / `UPDATE` SQL
|
|
275
|
+
from the UI without executing it. The preview modes only return the SQL
|
|
276
|
+
string; they never touch the database.
|
|
277
|
+
- **SQL dump** — export the whole database as a downloadable `CREATE` + `INSERT`
|
|
278
|
+
SQL file.
|
|
279
|
+
|
|
280
|
+
### 🗂️ Design & manage schema
|
|
281
|
+
|
|
282
|
+
- **Visual table designer** — create a table with name, type, primary key,
|
|
283
|
+
not-null / unique, default value, and foreign-key references, with a live
|
|
284
|
+
`CREATE TABLE` SQL preview.
|
|
285
|
+
- **Schema editor** — rename the table, add / rename / drop columns, and drop
|
|
286
|
+
tables, with relationship-safety checks: drops are refused when the column is
|
|
287
|
+
a primary key, has a UNIQUE constraint, is used by an index, is part of a
|
|
288
|
+
foreign key, or is referenced by another table's foreign key. Tables
|
|
289
|
+
referenced by other tables cannot be dropped. Internal (`_`-prefixed) tables
|
|
290
|
+
cannot be renamed or dropped.
|
|
291
|
+
- **Indexes** — create indexes (plain or unique, on one or many columns — pick
|
|
292
|
+
columns in order, with a live `CREATE INDEX` SQL preview) and drop them from
|
|
293
|
+
the schema editor; automatic SQLite (primary-key/unique) indexes are
|
|
294
|
+
protected.
|
|
295
|
+
|
|
296
|
+
### 🔄 Import, export & seed data
|
|
297
|
+
|
|
298
|
+
- **Export** — table rows or query results as **CSV or JSON** (a whole table or
|
|
299
|
+
only selected rows).
|
|
300
|
+
- **CSV import** — paste or upload CSV into a table; the header must match
|
|
301
|
+
existing columns, and the import runs in a single transaction (a failed row
|
|
302
|
+
rolls everything back).
|
|
303
|
+
- **Seed data generator** — fill a table with realistic rows in one go. Each
|
|
304
|
+
column gets an auto-detected strategy (first/last/full name, email, phone,
|
|
305
|
+
city, country, UUID, random integer/decimal/date/datetime/boolean/bytes, a few
|
|
306
|
+
words, a sentence, a fixed value, a random value from a list, or "skip — let
|
|
307
|
+
the DB default apply"); foreign-key columns can sample real values from the
|
|
308
|
+
referenced table. Insert up to 5,000 rows transactionally, or preview the
|
|
309
|
+
generated `INSERT` SQL without executing it.
|
|
310
|
+
|
|
311
|
+
### 🚀 Deploy
|
|
312
|
+
|
|
313
|
+
- **Read-only mode** — open the database(s) without write access: the file is
|
|
314
|
+
opened `SQLITE_OPEN_READONLY` + `query_only`, every write route returns `403`,
|
|
315
|
+
and the UI hides/disables all write controls and shows a banner.
|
|
316
|
+
- **Standalone CLI / file browser** — `admindb` runs as a full web app; with no
|
|
317
|
+
arguments it opens a **Databases** landing page where you can browse the
|
|
318
|
+
filesystem and open any SQLite database file, or create new ones. Flags set
|
|
319
|
+
the port, open a file, manage a folder, and more (`admindb --help`).
|
|
320
|
+
- **Multiple databases** — directory scanning and/or explicit file lists, each
|
|
321
|
+
with its own workspace under `/{db}/…`.
|
|
322
|
+
|
|
323
|
+
## Security warning
|
|
324
|
+
|
|
325
|
+
> ⚠️ **This tool exposes full, unauthenticated database AND filesystem access.**
|
|
326
|
+
> Every page and API route (browse, edit, delete, run arbitrary SQL, change the
|
|
327
|
+
> schema, export the whole database, and — in manager mode — browse the
|
|
328
|
+
> filesystem to open database files) is available to **anyone who can reach the
|
|
329
|
+
> server**.
|
|
330
|
+
>
|
|
331
|
+
> - **No authentication or authorization is built in.** The routes are **not
|
|
332
|
+
> protected**.
|
|
333
|
+
> - **It is your responsibility to protect access.** Do **not** expose
|
|
334
|
+
> AdminDB to the public internet or to untrusted networks.
|
|
335
|
+
> - Recommended ways to protect it:
|
|
336
|
+
> - bind the standalone server to `127.0.0.1` (`HOST=127.0.0.1`) and use it
|
|
337
|
+
> only from your own machine, and/or
|
|
338
|
+
> - run it behind a reverse proxy that requires authentication (Basic auth,
|
|
339
|
+
> OAuth, mTLS, …) or inside a VPN / private network.
|
|
340
|
+
>
|
|
341
|
+
> Treat AdminDB as if it were a remote `sqlite3` shell with write access.
|
|
342
|
+
|
|
343
|
+
## API
|
|
344
|
+
|
|
345
|
+
All routes live under `basePath` and return the consistent shape
|
|
346
|
+
`{ success, data?, error? }`. In multi-db mode, every route is scoped under the
|
|
347
|
+
database, e.g. `/api/app.db/tables`.
|
|
348
|
+
|
|
349
|
+
```text
|
|
350
|
+
GET /api/tables List tables
|
|
351
|
+
GET /api/tables/:table/rows Paginated rows (filters, sorting)
|
|
352
|
+
POST /api/tables/:table/rows Insert row
|
|
353
|
+
PUT /api/tables/:table/row/:id Update row
|
|
354
|
+
DELETE /api/tables/:table/row/:id Delete row
|
|
355
|
+
POST /api/query Run arbitrary SQL
|
|
356
|
+
POST /api/tables Create table
|
|
357
|
+
GET /api/tables/:table/export Download all rows as csv|json
|
|
358
|
+
POST /api/tables/:table/seed Generate and insert seed rows
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Plus bulk row operations, CSV import, schema and index management, saved
|
|
362
|
+
queries, a data generator — and, in manager mode, database-file management and
|
|
363
|
+
the filesystem browser.
|
|
364
|
+
|
|
365
|
+
> **Full reference:** every endpoint (including seed config/generate, bulk
|
|
366
|
+
> update/delete/export, and the multi-db manager endpoints) is documented in
|
|
367
|
+
> **[`docs/API.md`](docs/API.md)**.
|
|
368
|
+
|
|
369
|
+
**Behaviour notes:**
|
|
357
370
|
|
|
358
371
|
- **Empty input = "not set".** Empty form fields are omitted so DB defaults
|
|
359
|
-
apply; `0` is a valid value and is never treated as empty.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
`CURRENT_TIMESTAMP`-style defaults) so you can see and adjust them.
|
|
363
|
-
- **Row filters.** The filter panel adapts to each column's type: foreign keys
|
|
364
|
-
become dropdowns (with a "not set / NULL" option), booleans become
|
|
365
|
-
any/true/false toggles, and dates and numbers become min/max range inputs.
|
|
366
|
-
Text columns keep the operator syntax: exact match (`=value`), comparison
|
|
367
|
-
(`>5`, `>=5`, `<5`, `<=5`, `!=value`), prefix (`pre*`) and case-insensitive
|
|
368
|
-
substring (plain text). Filters are carried in the URL (as legacy strings or
|
|
369
|
-
structured conditions) and survive sorting and pagination.
|
|
372
|
+
apply; `0` is a valid value and is never treated as empty. Insert forms
|
|
373
|
+
pre-fill column defaults from the schema (string/number/boolean literals and
|
|
374
|
+
`CURRENT_TIMESTAMP`-style defaults).
|
|
370
375
|
- **Inline editing is staged, not instant.** Double-click a cell to edit it in
|
|
371
376
|
place; edits are buffered locally and highlighted in the grid rather than
|
|
372
|
-
written immediately. Press **Apply** to write every pending change
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
only the selected rows. Both delete and export are capped at 1000 rows per
|
|
382
|
-
batch.
|
|
383
|
-
- **CSV import.** The first row must be a header whose names match existing
|
|
384
|
-
columns (unknown or duplicate names are rejected). Empty cells are treated as
|
|
385
|
-
"not set" so database defaults apply. The whole import runs in a single
|
|
386
|
-
transaction — a failed row rolls everything back.
|
|
387
|
-
- **Indexes.** Creating an index takes one or more columns and an optional
|
|
388
|
-
unique flag (the index name is optional too). Only explicitly created indexes
|
|
389
|
-
(`origin = 'c'`) can be dropped from the UI — automatic primary-key/unique
|
|
390
|
-
indexes are protected.
|
|
391
|
-
- **Schema editor.** Drops are refused when the column is a primary key, has a
|
|
392
|
-
UNIQUE constraint, is used by an index, is part of a foreign key, or is
|
|
393
|
-
referenced by another table's foreign key. Tables referenced by other tables
|
|
394
|
-
cannot be dropped. Internal (`_`-prefixed) tables cannot be renamed or dropped.
|
|
377
|
+
written immediately. Press **Apply** to write every pending change in a single
|
|
378
|
+
transaction (the page then reloads so related-row counts stay accurate), or
|
|
379
|
+
**Discard** to revert. Clearing a text/date/number field stages a `NULL`.
|
|
380
|
+
- **Bulk operations** run per page with "select all"; delete first shows an
|
|
381
|
+
FK-impact warning (rows may be cascaded away or orphaned depending on the
|
|
382
|
+
foreign-key action, and the delete can fail if a constraint blocks it). Both
|
|
383
|
+
delete and export are capped at 1000 rows per batch.
|
|
384
|
+
- **CSV import** runs in a single transaction — a failed row rolls everything
|
|
385
|
+
back.
|
|
395
386
|
- **Identifiers are quoted and string values escaped** everywhere SQL is built,
|
|
396
|
-
so generated SQL is correct and safe
|
|
387
|
+
so generated SQL is correct and safe; **"Get query" never executes** — it only
|
|
388
|
+
returns the generated SQL string.
|
|
397
389
|
- **`COUNT` queries** return a readable summary message instead of a table.
|
|
398
|
-
- **"Get query" never executes** — it only returns the generated SQL string.
|
|
399
390
|
- **Internal table** `_saved_queries` stores saved queries and is kept out of
|
|
400
391
|
user-facing FK pickers. Schema initialization is idempotent and safe to run
|
|
401
392
|
repeatedly.
|
|
402
|
-
- Composite primary keys are supported (values are URL-encoded and comma-joined
|
|
403
|
-
in the row endpoints).
|
|
404
|
-
|
|
405
|
-
## Development
|
|
406
|
-
|
|
407
|
-
```bash
|
|
408
|
-
npm install
|
|
409
|
-
npm run build # TypeScript → dist + Tailwind CSS
|
|
410
|
-
npm run dev # tsx watch server + Tailwind watch
|
|
411
|
-
npm test # builds and runs the unit tests
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
`npm test` compiles TypeScript to `dist/` and runs the `node:test` suite
|
|
415
|
-
covering the SQL generator (INSERT / UPDATE / CREATE output, type mapping,
|
|
416
|
-
quoting, rejection of unsupported types), the SQL classifier, CSV parsing and
|
|
417
|
-
serialization, row filters (legacy and structured conditions), the database
|
|
418
|
-
layer (pagination, transactions, bulk update/delete, read-only enforcement),
|
|
419
|
-
and the database manager.
|
|
420
393
|
|
|
421
|
-
##
|
|
422
|
-
|
|
423
|
-
The package ships the compiled `dist/` (with type declarations), this `README`,
|
|
424
|
-
and the `LICENSE`. When you are ready to publish:
|
|
425
|
-
|
|
426
|
-
```bash
|
|
427
|
-
npm run build # happens automatically via the prepack script
|
|
428
|
-
npm login
|
|
429
|
-
npm publish
|
|
430
|
-
```
|
|
394
|
+
## Contributing
|
|
431
395
|
|
|
432
|
-
|
|
433
|
-
and
|
|
396
|
+
PRs are welcome. Development workflow (`npm run dev` for live reload, `npm test`
|
|
397
|
+
to build and run the unit suite), project layout, and contribution guidelines
|
|
398
|
+
live in **[`CONTRIBUTING.md`](CONTRIBUTING.md)**.
|
|
434
399
|
|
|
435
400
|
## License
|
|
436
401
|
|