db-model-router 1.0.16 → 1.0.18

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.
@@ -1,23 +1,25 @@
1
- # the name by which the project can be referenced within Serena
1
+ # the name by which the project can be referenced within Serena/when chatting with the LLM.
2
2
  project_name: "db-model-router"
3
3
 
4
-
5
- # list of languages for which language servers are started; choose from:
6
- # al angular ansible bash clojure
7
- # cpp cpp_ccls crystal csharp csharp_omnisharp
8
- # dart elixir elm erlang fortran
9
- # fsharp go groovy haskell haxe
10
- # hlsl html java json julia
11
- # kotlin lean4 lua luau markdown
4
+ # list of languages for which language servers are started (LSP backend only); choose from:
5
+ # ada al angular ansible bash
6
+ # bsl clojure cpp cpp_ccls crystal
7
+ # csharp csharp_omnisharp cue dart elixir
8
+ # elm erlang fortran fsharp gdscript
9
+ # go groovy haskell haxe hlsl
10
+ # html java json julia kotlin
11
+ # latex lean4 lua luau markdown
12
12
  # matlab msl nix ocaml pascal
13
- # perl php php_phpactor powershell python
14
- # python_jedi python_ty r rego ruby
15
- # ruby_solargraph rust scala scss solidity
16
- # svelte swift systemverilog terraform toml
17
- # typescript typescript_vts vue yaml zig
18
- # (This list may be outdated. For the current list, see values of Language enum here:
19
- # https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
20
- # For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
13
+ # perl php php_phpactor php_phpantom powershell
14
+ # python python_jedi python_pyrefly python_ty r
15
+ # rego ruby ruby_solargraph rust scala
16
+ # scss solidity svelte swift systemverilog
17
+ # terraform toml typescript typescript_vts vue
18
+ # yaml zig
19
+ # (This list may be outdated; generated with scripts/print_language_list.py;
20
+ # For the current list, see values of Language enum here:
21
+ # https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py)
22
+ # For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
21
23
  # Note:
22
24
  # - For C, use cpp
23
25
  # - For JavaScript, use typescript
@@ -55,21 +57,10 @@ ignore_all_files_in_gitignore: true
55
57
 
56
58
  # advanced configuration option allowing to configure language server-specific options.
57
59
  # Maps the language key to the options.
58
- # Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
59
- # No documentation on options means no options are available.
60
+ # The settings are considered only if the project is trusted (see global configuration to define trusted projects).
61
+ # See https://oraios.github.io/serena/02-usage/050_configuration.html#language-server-specific-settings
60
62
  ls_specific_settings: {}
61
63
 
62
- # list of additional workspace folder paths for cross-package reference support (e.g. in monorepos).
63
- # Paths can be absolute or relative to the project root.
64
- # Each folder is registered as an LSP workspace folder, enabling language servers to discover
65
- # symbols and references across package boundaries.
66
- # Currently supported for: TypeScript.
67
- # Example:
68
- # additional_workspace_folders:
69
- # - ../sibling-package
70
- # - ../shared-lib
71
- additional_workspace_folders: []
72
-
73
64
  # list of additional paths to ignore in this project.
74
65
  # Same syntax as gitignore, so you can use * and **.
75
66
  # Note: global ignored_paths from serena_config.yml are also applied additively.
@@ -131,3 +122,39 @@ read_only_memory_patterns: []
131
122
  # Extends the list from the global configuration, merging the two lists.
132
123
  # Example: ["_archive/.*", "_episodes/.*"]
133
124
  ignored_memory_patterns: []
125
+
126
+ # list of additional workspace folder paths for cross-package reference support.
127
+ # Paths can be absolute or relative to the project root.
128
+ # Each folder is registered as an LSP workspace folder, enabling language servers to discover
129
+ # symbols and references across package boundaries, but these folders are not indexed by Serena,
130
+ # i.e. the respective symbols will not be found using Serena's symbol search tools.
131
+ # Example:
132
+ # additional_workspace_folders:
133
+ # - ../sibling-package
134
+ # - ../shared-lib
135
+ ls_additional_workspace_folders: []
136
+
137
+ # list of workspace folder paths (LSP backend only).
138
+ # These folders will be used to build up Serena's symbol index.
139
+ # Paths must be within the project root and should thus be relative to the project root.
140
+ # Furthermore, the paths should not be filtered by ignore settings.
141
+ # Default setting: The entire project root folder (".") is considered.
142
+ # In (large) monorepos, this can be used to index only subfolders of the project root, e.g.
143
+ # ls_workspace_folders:
144
+ # - "./subproject1"
145
+ # - "./subproject2"
146
+ ls_workspace_folders:
147
+ - .
148
+
149
+ # optional shell command to run before the language backend (LSP or JetBrains) is initialised.
150
+ # the command runs in the project root directory and is only executed if the project is trusted
151
+ # (see trusted_project_path_patterns in the global configuration).
152
+ # serena waits for the command to exit: a non-zero exit code is logged as an error but does not
153
+ # abort activation. a per-project timeout (activation_command_timeout, default 180s) is the safety
154
+ # backstop for non-terminating commands; on expiry the process is killed and activation continues.
155
+ # example: activation_command: "npx nx run-many -t build"
156
+ activation_command:
157
+
158
+ # maximum time in seconds to wait for activation_command to complete before killing it (default 180s).
159
+ # must be a positive number.
160
+ activation_command_timeout: 180.0
package/README.md CHANGED
@@ -79,12 +79,9 @@ Both `express` and `ultimate-express` are optional peer dependencies. The librar
79
79
  The fastest way to start a new project:
80
80
 
81
81
  ```bash
82
- # Scaffold a project interactively
82
+ # Build a full project from a schema file (first buildout only)
83
83
  npx db-model-router init
84
-
85
- # Or fully non-interactive from a schema file
86
- db-model-router init --from dbmr.schema.json --yes --no-install
87
- db-model-router generate --from dbmr.schema.json
84
+ # → reads ./dbmr.schema.json, scaffolds app.js + models + routes + migrations + tests + OpenAPI + SaaS
88
85
  ```
89
86
 
90
87
  After scaffolding:
@@ -137,7 +134,11 @@ Examples of tables that should stay top-level (not be parents of feature modules
137
134
  "rateLimiting": true,
138
135
  "helmet": true,
139
136
  "logger": true,
140
- "loki": false
137
+ "loki": false,
138
+ "output": null,
139
+ "saasStructure": true,
140
+ "apiBasePath": "/api",
141
+ "port": 3000
141
142
  },
142
143
  "tables": {
143
144
  "users": {
@@ -247,19 +248,20 @@ For the full column rule specification including all sub-types and validators, s
247
248
 
248
249
  ### Unified CLI: `db-model-router`
249
250
 
250
- The `db-model-router` command is the unified entry point with five subcommands:
251
+ The `db-model-router` command is the unified entry point. `init` is the only buildout command — it reads `dbmr.schema.json` and produces the whole project. The other subcommands are introspection, validation, and a DB manager UI.
251
252
 
252
253
  ```bash
253
254
  db-model-router <subcommand> [flags]
254
255
  ```
255
256
 
256
- | Subcommand | Description |
257
- | ---------- | ------------------------------------------------------------------- |
258
- | `init` | Scaffold a new project (optionally from a schema file) |
259
- | `inspect` | Introspect a live database and produce a `dbmr.schema.json` |
260
- | `generate` | Generate models, routes, tests, and OpenAPI spec from the schema |
261
- | `doctor` | Validate schema, check dependencies, verify generated files in sync |
262
- | `diff` | Preview what changes regeneration would make (read-only) |
257
+ | Subcommand | Description |
258
+ | ------------- | -------------------------------------------------------------------- |
259
+ | `init` | **First buildout only.** Scaffold the full project from `dbmr.schema.json` |
260
+ | `inspect` | Introspect a live database and produce a `dbmr.schema.json` |
261
+ | `doctor` | Validate schema, check dependencies, verify generated files in sync |
262
+ | `diff` | Preview what changes regeneration would make (read-only) |
263
+ | `db-manager` | Start a live database management UI |
264
+ | `help` | Show help for a command |
263
265
 
264
266
  #### Universal Flags
265
267
 
@@ -267,10 +269,9 @@ All subcommands accept these flags:
267
269
 
268
270
  | Flag | Description |
269
271
  | -------------- | ----------------------------------------------------------- |
270
- | `--yes` | Accept all defaults, suppress interactive prompts |
271
272
  | `--json` | Output machine-readable JSON instead of human-readable text |
272
273
  | `--dry-run` | Preview actions without writing files or running commands |
273
- | `--no-install` | Skip `npm install` (applies to commands that would run it) |
274
+ | `--no-install` | Skip `npm install` (applies to `init`) |
274
275
  | `--help` | Show usage information for the subcommand |
275
276
 
276
277
  #### Quick Workflow Example
@@ -279,10 +280,11 @@ All subcommands accept these flags:
279
280
  # 1. Introspect an existing database into a schema file
280
281
  db-model-router inspect --type postgres --env .env
281
282
 
282
- # 2. (Optional) Edit dbmr.schema.json to tweak columns, set parent for nesting, etc.
283
+ # 2. (Optional) Edit dbmr.schema.json tweak columns, set parent for nesting,
284
+ # set options.output / options.saasStructure / options.apiBasePath / options.port
283
285
 
284
- # 3. Generate all artifacts from the schema
285
- db-model-router generate --from dbmr.schema.json
286
+ # 3. Build the full project (first buildout only)
287
+ db-model-router init
286
288
 
287
289
  # 4. Check everything is in sync
288
290
  db-model-router doctor --from dbmr.schema.json
@@ -291,58 +293,101 @@ db-model-router doctor --from dbmr.schema.json
291
293
  db-model-router diff --from dbmr.schema.json
292
294
  ```
293
295
 
294
- Or start a brand-new project from a schema file:
295
-
296
- ```bash
297
- # Scaffold project + generate everything in one go
298
- db-model-router init --from dbmr.schema.json --yes --no-install
299
- db-model-router generate --from dbmr.schema.json
300
- ```
301
-
302
296
  ### Command Reference
303
297
 
304
298
  #### `init`
305
299
 
306
- Scaffold a new project from a schema file or interactively. Generates an ESM-based project (`"type": "module"` in package.json) with Docker support.
307
-
308
- | Flag / Arg | Description |
309
- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
310
- | `--from <path>` | Read adapter, framework, and options from a `dbmr.schema.json` file |
311
- | `--framework <name>` | Express framework: `express` or `ultimate-express` |
312
- | `--database <name>` | Database adapter: `mysql`, `mariadb`, `postgres`, `sqlite3`, `mongodb`, `mssql`, `cockroachdb`, `oracle`, `redis`, `dynamodb` |
313
- | `--db <name>` | Alias for `--database` |
314
- | `--session <type>` | Session store: `memory`, `redis`, `database` |
315
- | `--output <dir>` | Directory for backend source files (relative to cwd). `package.json` and `app.js` stay in root; `commons/`, `route/`, `middleware/`, `migrations/` go inside this folder. |
316
- | `--rateLimiting` | Enable rate limiting via `express-rate-limit` (default: yes) |
317
- | `--helmet` | Enable Helmet security headers (default: yes) |
318
- | `--logger` | Enable Winston request logger (default: yes) |
319
- | `--loki` | Enable Grafana Loki log transport + Loki/Grafana in docker-compose (default: no, only asked when `--logger` is enabled) |
300
+ **First buildout only.** Scaffolds the full project from `dbmr.schema.json`: `app.js`, `commons/`, `routes/`, `middleware/`, `migrations/`, `models/`, `tests/`, `openapi.json`, and the optional SaaS structure. All project config lives in the schema's `options` block — `init` takes no config flags. `init` refuses to run if a project already exists in cwd (`app.js` present); to add new tables/models/routes after buildout, do it manually (see below).
301
+
302
+ Generates an ESM-based project (`"type": "module"` in package.json) with Docker support.
303
+
304
+ | Arg / Flag | Description |
305
+ | ---------------- | -------------------------------------------------------------------- |
306
+ | `[schemaPath]` | Path to schema file (default: `./dbmr.schema.json`) |
307
+ | `--dry-run` | Preview planned files without writing |
308
+ | `--no-install` | Skip `npm install` after scaffolding |
309
+ | `--json` | Machine-readable JSON output |
310
+ | `--help` | Show detailed help (includes the manual add procedure) |
311
+
312
+ All configuration is read from `options` in `dbmr.schema.json`:
313
+
314
+ | Option | Default | Description |
315
+ | ---------------- | ----------- | ------------------------------------------------------------------------------------------------- |
316
+ | `output` | `null` (cwd)| Directory for backend source files. `package.json`/`app.js` stay in root; the rest go inside it. |
317
+ | `saasStructure` | `true` | Generate the multi-tenant SaaS backend (tables, middleware, routes, seeds). |
318
+ | `apiBasePath` | `"/api"` | Base path the API is mounted at (written to `.env` as `API_BASE_PATH`). |
319
+ | `port` | `3000` | Server port (written to `.env` as `PORT`). |
320
+ | `session` | `"memory"` | Session store: `memory`, `redis`, `database`. |
321
+ | `rateLimiting` | `true` | Enable `express-rate-limit`. |
322
+ | `helmet` | `true` | Enable Helmet security headers. |
323
+ | `logger` | `true` | Enable Winston request logger. |
324
+ | `loki` | `false` | Enable Grafana Loki log transport + Loki/Grafana in docker-compose. |
320
325
 
321
326
  ```bash
322
- # Non-interactive with output directory
323
- db-model-router init --framework express --database postgres --output backend --yes
327
+ # Build the full project from ./dbmr.schema.json
328
+ db-model-router init
324
329
 
325
- # With Loki logging
326
- db-model-router init --database postgres --logger --loki --yes
330
+ # Use a specific schema file
331
+ db-model-router init ./my.schema.json
327
332
 
328
- # From schema, skip install
329
- db-model-router init --from dbmr.schema.json --yes --no-install
333
+ # Preview without writing
334
+ db-model-router init --dry-run
330
335
 
331
- # Dry run to preview files
332
- db-model-router init --from dbmr.schema.json --dry-run
336
+ # Skip npm install
337
+ db-model-router init --no-install
333
338
  ```
334
339
 
335
- Generated project structure (with `--output backend`):
340
+ ##### `options.saasStructure` SaaS Multi-Tenant Architecture (default: enabled)
341
+
342
+ The SaaS structure is generated unless `options.saasStructure` is `false`. It scaffolds a complete multi-tenant SaaS backend on top of your schema-generated code:
343
+
344
+ - **Tables**: `tenants`, `users`, `roles`, `role_permissions`, `webhooks`, `webhook_logs`
345
+ - **Middleware**: `authenticate`, `tenantIsolation`, `hasPermission`
346
+ - **Routes**: CRUD for users/tenants/roles/permissions + auth (login/logout)
347
+ - **Utilities**: password hashing (crypto.scrypt), modules registry, webhook delivery with retry
348
+ - **Seeds**: Super Admin user + Tenant Admin role template
349
+ - **Migrations**: Single consolidated migration file for all SaaS tables
350
+
351
+ > **Important**: Since `saasStructure` is on by default, the tables `users`, `tenants`, `roles`, and `role_permissions` are already generated with their models, routes, and migrations. **Do not add these tables to your `dbmr.schema.json`** — they will be duplicated. Only define your product/domain-specific tables in the schema (e.g., `products`, `orders`, `invoices`).
352
+
353
+ The generated `routes/index.js` automatically combines both SaaS routes (under `/api/auth`, `/api/users`, `/api/tenants`, `/api/roles`) and your schema-generated product routes. The OpenAPI/Swagger docs include all SaaS endpoints with security annotations.
354
+
355
+ ##### Adding new tables / models / routes after buildout (manual)
356
+
357
+ `init` is first-buildout only. Do not re-run it to add tables. Instead:
358
+
359
+ 1. **Migration** — create a new timestamped migration under `migrations/` with the `CREATE TABLE` (SQL) or `create_<table>.js` (NoSQL):
360
+ ```bash
361
+ node commons/add_migration.js <name>
362
+ # then write your CREATE TABLE SQL / collection setup inside the new file
363
+ ```
364
+ 2. **Model** — add `models/<table>.js` mirroring an existing model:
365
+ ```js
366
+ const model = require('#commons/model');
367
+ const db = require('#commons/db');
368
+ module.exports = model(db, '<table>', structure, '<pk>', uniqueKeys, option);
369
+ ```
370
+ 3. **Route** — add `routes/<table>/index.js` via `route(model)`, then mount it in `routes/index.js` at the desired endpoint:
371
+ ```js
372
+ // routes/<table>/index.js
373
+ const route = require('#commons/route');
374
+ module.exports = route(require('#models/<table>'));
375
+ // routes/index.js
376
+ router.use('/<endpoint>', require('./<table>/index.js'));
377
+ ```
378
+ 4. Run the new migration, then restart the server.
379
+
380
+ Generated project structure (with `options.output = "backend"`):
336
381
 
337
382
  ```
338
383
  ├── package.json # root (type: "module")
339
384
  ├── app.js # ESM entry point
340
- ├── .env / .env.example
385
+ ├── .env / .env.example # PORT, API_BASE_PATH, DB creds
341
386
  ├── .gitignore
342
387
  ├── Dockerfile # node:alpine production image
343
388
  ├── .dockerignore
344
389
  ├── docker-compose.yml # database + optional Loki/Grafana
345
- ├── .grafana/ # (only when --loki)
390
+ ├── .grafana/ # (only when options.loki)
346
391
  │ └── datasources.yml # auto-connects Grafana to Loki
347
392
  └── backend/
348
393
  ├── commons/
@@ -353,21 +398,30 @@ Generated project structure (with `--output backend`):
353
398
  │ └── add_migration.js # migration creator (importable + standalone script)
354
399
  ├── middleware/
355
400
  │ └── logger.js # Winston logger (+ Loki transport when LOKI_HOST is set)
356
- ├── route/
357
- │ ├── index.js # central route mounting
358
- └── health.js # GET /health with DB connectivity check
359
- └── migrations/
360
- └── <timestamp>_create_migrations_table.sql
401
+ ├── routes/
402
+ │ ├── index.js # central route mounting (SaaS + product routes)
403
+ ├── health.js # GET /health with DB connectivity check
404
+ │ ├── docs.js # Swagger UI at /docs
405
+ └── <table>/index.js # CRUD route per table (nested by parent)
406
+ ├── models/
407
+ │ └── <table>.js # model per table
408
+ ├── migrations/
409
+ │ └── <timestamp>_create_tables.sql # all tables (SQL) or per-table (NoSQL)
410
+ ├── test/
411
+ │ └── <table>.test.js # CRUD endpoint tests per table
412
+ ├── seeds/ # (when saasStructure=true)
413
+ │ └── saas-seed.js
414
+ └── openapi.json
361
415
  ```
362
416
 
363
417
  Docker services included automatically:
364
418
 
365
- | Service | When | Port | Description |
366
- | ----------- | ------------------------------------- | ------ | -------------------------------------- |
367
- | Database | Always (except sqlite3) | Varies | Selected database with random password |
368
- | Redis | `--session redis` (if DB isn't redis) | 6379 | Session store |
369
- | Loki | `--loki` | 3100 | Log aggregation |
370
- | Grafana | `--loki` | 3001 | Log visualization, Loki pre-configured |
419
+ | Service | When | Port | Description |
420
+ | ----------- | --------------------------------------------- | ------ | -------------------------------------- |
421
+ | Database | Always (except sqlite3) | Varies | Selected database with random password |
422
+ | Redis | `options.session = "redis"` (if DB isn't redis) | 6379 | Session store |
423
+ | Loki | `options.loki = true` | 3100 | Log aggregation |
424
+ | Grafana | `options.loki = true` | 3001 | Log visualization, Loki pre-configured |
371
425
 
372
426
  npm scripts added: `start`, `dev`, `test`, `migrate`, `add_migration`, `docker:build`, `docker:up`, `docker:down`.
373
427
 
@@ -388,47 +442,6 @@ db-model-router inspect --type sqlite3 --out schema.json --tables users,posts
388
442
  db-model-router inspect --type mysql --json
389
443
  ```
390
444
 
391
- #### `generate`
392
-
393
- Generate models, routes, tests, OpenAPI spec, and LLM docs from a schema file. All generated code is ESM (`import`/`export`).
394
-
395
- | Flag / Arg | Description |
396
- | ------------------------ | ------------------------------------------------- |
397
- | `--from <path>` | Path to schema file (default: `dbmr.schema.json`) |
398
- | `--output <dir>` | Directory for generated files (default: cwd) |
399
- | `--models=false` | Disable model file generation |
400
- | `--routes=false` | Disable route file generation |
401
- | `--openapi=false` | Disable OpenAPI spec generation |
402
- | `--tests=false` | Disable test file generation |
403
- | `--migrations=false` | Disable migration file generation |
404
- | `--saas-structure=false` | Disable SaaS multi-tenant generation |
405
-
406
- All artifact types are **enabled by default**. Use `--flag=false` to disable specific ones.
407
-
408
- ##### `--saas-structure` — SaaS Multi-Tenant Architecture (default: enabled)
409
-
410
- The SaaS structure is always generated unless explicitly disabled with `--saas-structure=false`. It scaffolds a complete multi-tenant SaaS backend on top of your schema-generated code:
411
-
412
- - **Tables**: `tenants`, `users`, `roles`, `role_permissions`, `webhooks`, `webhook_logs`
413
- - **Middleware**: `authenticate`, `tenantIsolation`, `hasPermission`
414
- - **Routes**: CRUD for users/tenants/roles/permissions + auth (login/logout)
415
- - **Utilities**: password hashing (crypto.scrypt), modules registry, webhook delivery with retry
416
- - **Seeds**: Super Admin user + Tenant Admin role template
417
- - **Migrations**: Single consolidated migration file for all SaaS tables
418
-
419
- > **Important**: Since `--saas-structure` is on by default, the tables `users`, `tenants`, `roles`, and `role_permissions` are already generated with their models, routes, and migrations. **Do not add these tables to your `dbmr.schema.json`** — they will be duplicated. Only define your product/domain-specific tables in the schema (e.g., `products`, `orders`, `invoices`).
420
-
421
- The generated `routes/index.js` automatically combines both SaaS routes (under `/api/auth`, `/api/users`, `/api/tenants`, `/api/roles`) and your schema-generated product routes. The OpenAPI/Swagger docs include all SaaS endpoints with security annotations.
422
-
423
- ```bash
424
- db-model-router generate --from dbmr.schema.json
425
- db-model-router generate --tests=false --dry-run # skip tests
426
- db-model-router generate --saas-structure=false # skip SaaS generation
427
- db-model-router generate --openapi=false --tests=false # skip OpenAPI and tests
428
- db-model-router generate --from dbmr.schema.json --json
429
- db-model-router generate --from dbmr.schema.json --output ./backend
430
- ```
431
-
432
445
  #### `doctor`
433
446
 
434
447
  Validate schema, check adapter driver dependencies, and verify generated files are in sync.
@@ -6,7 +6,11 @@
6
6
  "rateLimiting": true,
7
7
  "helmet": true,
8
8
  "logger": true,
9
- "loki": false
9
+ "loki": false,
10
+ "output": null,
11
+ "saasStructure": true,
12
+ "apiBasePath": "/api",
13
+ "port": 3000
10
14
  },
11
15
  "tables": {
12
16
  "projects": {
@@ -6,7 +6,11 @@
6
6
  "rateLimiting": true,
7
7
  "helmet": true,
8
8
  "logger": true,
9
- "loki": false
9
+ "loki": false,
10
+ "output": null,
11
+ "saasStructure": true,
12
+ "apiBasePath": "/api",
13
+ "port": 3000
10
14
  },
11
15
  "tables": {
12
16
  "template_survey": {
package/dbmr.schema.json CHANGED
@@ -6,7 +6,11 @@
6
6
  "rateLimiting": true,
7
7
  "helmet": true,
8
8
  "logger": true,
9
- "loki": false
9
+ "loki": false,
10
+ "output": null,
11
+ "saasStructure": true,
12
+ "apiBasePath": "/api",
13
+ "port": 3000
10
14
  },
11
15
  "tables": {
12
16
  "addresses": {
@@ -15,7 +15,11 @@ This document is the single source of truth for writing a `dbmr.schema.json` fil
15
15
  "rateLimiting": true,
16
16
  "helmet": true,
17
17
  "logger": true,
18
- "loki": false
18
+ "loki": false,
19
+ "output": null,
20
+ "saasStructure": true,
21
+ "apiBasePath": "/api",
22
+ "port": 3000
19
23
  },
20
24
  "tables": { ... }
21
25
  }
@@ -25,9 +29,25 @@ This document is the single source of truth for writing a `dbmr.schema.json` fil
25
29
  | ----------- | -------- | ------------------------------------------------------------------------------ |
26
30
  | `adapter` | Yes | Database adapter. One of: `mysql`, `mariadb`, `postgres`, `sqlite3`, `mongodb`, `mssql`, `cockroachdb`, `oracle`, `redis`, `dynamodb` |
27
31
  | `framework` | Yes | Express variant. One of: `express`, `ultimate-express` |
28
- | `options` | No | Project scaffolding options (session store, rate limiting, helmet, logger, loki) |
32
+ | `options` | No | Project buildout config see `options` reference below |
29
33
  | `tables` | Yes | Object where each key is a table name and the value is a **Table Definition** |
30
34
 
35
+ ### `options` reference
36
+
37
+ All project configuration lives in `options`. `db-model-router init` reads these and takes no config flags.
38
+
39
+ | Option | Required | Default | Description |
40
+ | ---------------- | -------- | ----------- | ------------------------------------------------------------------------------------------------- |
41
+ | `output` | No | `null` (cwd)| Directory for backend source files. `package.json`/`app.js` stay in root; the rest go inside it. |
42
+ | `saasStructure` | No | `true` | Generate the multi-tenant SaaS backend (tables, middleware, routes, seeds). |
43
+ | `apiBasePath` | No | `"/api"` | Base path the API is mounted at (written to `.env` as `API_BASE_PATH`). |
44
+ | `port` | No | `3000` | Server port (written to `.env` as `PORT`). |
45
+ | `session` | No | `"memory"` | Session store: `memory`, `redis`, `database`. |
46
+ | `rateLimiting` | No | `true` | Enable `express-rate-limit`. |
47
+ | `helmet` | No | `true` | Enable Helmet security headers. |
48
+ | `logger` | No | `true` | Enable Winston request logger. |
49
+ | `loki` | No | `false` | Enable Grafana Loki log transport + Loki/Grafana in docker-compose. |
50
+
31
51
  ---
32
52
 
33
53
  ## Table Definition
@@ -307,7 +327,7 @@ In the schema file, this is expressed by placing dot-notation keys alongside the
307
327
 
308
328
  ## SaaS Auto-Generated Tables
309
329
 
310
- When you run `db-model-router generate` (or `db-model-router init`), the **SaaS structure is generated by default** unless you explicitly disable it with `--saas-structure=false`.
330
+ When you run `db-model-router init`, the **SaaS structure is generated by default** unless you explicitly disable it by setting `options.saasStructure` to `false` in `dbmr.schema.json`.
311
331
 
312
332
  The following tables, middleware, routes, and seeds are scaffolded automatically. **Do NOT add these tables to your `dbmr.schema.json`** — doing so will cause duplication errors.
313
333
 
@@ -520,7 +540,11 @@ GET /products/?search=alice&sku=ABC
520
540
  "rateLimiting": true,
521
541
  "helmet": true,
522
542
  "logger": true,
523
- "loki": false
543
+ "loki": false,
544
+ "output": null,
545
+ "saasStructure": true,
546
+ "apiBasePath": "/api",
547
+ "port": 3000
524
548
  },
525
549
  "tables": {
526
550
  "products": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "db-model-router",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Generative API Creation using mysql2 and express libraries in node js",
5
5
  "main": "src/index.js",
6
6
  "bin": {