@kollors/deep-json-server 1.0.0-beta.6 → 1.0.0-rc.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/MIGRATION.md +41 -0
  3. package/README.md +73 -38
  4. package/README.ru.md +87 -52
  5. package/dist/src/cli/index.js +7 -7
  6. package/dist/src/cli/index.js.map +1 -1
  7. package/dist/src/core/config-values.js +4 -4
  8. package/dist/src/core/config-values.js.map +1 -1
  9. package/dist/src/core/constants.d.ts +1 -1
  10. package/dist/src/core/constants.js +1 -1
  11. package/dist/src/core/constants.js.map +1 -1
  12. package/dist/src/core/database.js +16 -16
  13. package/dist/src/core/database.js.map +1 -1
  14. package/dist/src/core/model/infer.js +2 -2
  15. package/dist/src/core/model/infer.js.map +1 -1
  16. package/dist/src/core/model/load.js +9 -4
  17. package/dist/src/core/model/load.js.map +1 -1
  18. package/dist/src/core/model/policy.d.ts +1 -1
  19. package/dist/src/core/model/policy.js +4 -3
  20. package/dist/src/core/model/policy.js.map +1 -1
  21. package/dist/src/core/model/types.d.ts +5 -3
  22. package/dist/src/core/utils.js +2 -2
  23. package/dist/src/core/utils.js.map +1 -1
  24. package/dist/src/files/contract.js +8 -8
  25. package/dist/src/files/contract.js.map +1 -1
  26. package/dist/src/files/disk-metadata.js +3 -3
  27. package/dist/src/files/disk-metadata.js.map +1 -1
  28. package/dist/src/files/disk-paths.js +6 -6
  29. package/dist/src/files/disk-paths.js.map +1 -1
  30. package/dist/src/files/disk-store.js +10 -10
  31. package/dist/src/files/disk-store.js.map +1 -1
  32. package/dist/src/files/memory-store.js +8 -8
  33. package/dist/src/files/memory-store.js.map +1 -1
  34. package/dist/src/files/routes.js +9 -9
  35. package/dist/src/files/routes.js.map +1 -1
  36. package/dist/src/files/streams.js +1 -1
  37. package/dist/src/files/streams.js.map +1 -1
  38. package/dist/src/openapi/document.d.ts +3 -2
  39. package/dist/src/openapi/document.js +5 -4
  40. package/dist/src/openapi/document.js.map +1 -1
  41. package/dist/src/openapi/generate.js +8 -3
  42. package/dist/src/openapi/generate.js.map +1 -1
  43. package/dist/src/openapi/options.d.ts +1 -0
  44. package/dist/src/rest/routes.js +2 -2
  45. package/dist/src/rest/routes.js.map +1 -1
  46. package/dist/src/server/bootstrap.js +7 -2
  47. package/dist/src/server/bootstrap.js.map +1 -1
  48. package/dist/src/server/config.d.ts +1 -5
  49. package/dist/src/server/config.js +5 -5
  50. package/dist/src/server/config.js.map +1 -1
  51. package/dist/src/server/create.js +1 -1
  52. package/dist/src/server/create.js.map +1 -1
  53. package/dist/src/server/http.js +1 -1
  54. package/dist/src/server/http.js.map +1 -1
  55. package/dist/src/server/model.js +10 -2
  56. package/dist/src/server/model.js.map +1 -1
  57. package/dist/src/server/openapi-options.d.ts +2 -1
  58. package/dist/src/server/openapi-options.js +2 -1
  59. package/dist/src/server/openapi-options.js.map +1 -1
  60. package/dist/src/server/public.d.ts +1 -1
  61. package/dist/src/server/public.js.map +1 -1
  62. package/examples/database.json +99 -0
  63. package/examples/schema.json +149 -0
  64. package/examples/server.config.js +8 -0
  65. package/package.json +5 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0-rc.2
4
+
5
+ - Added root schema `api` to select REST, GraphQL, or both for database routes, and per-model `api` selection with matching formats. Authentication and file routes remain REST endpoints; OpenAPI includes only enabled REST routes.
6
+ - GraphQL-only server configurations no longer require package metadata. OpenAPI keeps authentication and file routes when no database model enables REST.
7
+ - Added installed-package coverage for per-model API selection and checks for code examples in both READMEs.
8
+
9
+ ## 1.0.0-rc.1
10
+
11
+ First release candidate for the 1.0 API. This release includes schema-driven REST, GraphQL, OpenAPI export, authentication, record ownership, timestamps, soft deletion, and file storage. It also makes CLI and API error messages consistently English and checks TypeScript declarations from an installed package archive.
12
+
13
+ The 1.0 configuration, CLI flags, and REST query format differ from 0.9.0. Follow the [migration guide](MIGRATION.md) before upgrading an existing project. In particular, the REST `scope` wildcard includes scalar fields only; select arrays, objects, relations, and relation keys explicitly.
14
+
15
+ ### Verification
16
+
17
+ - TypeScript source and contract checks, lint, and coverage-gated tests.
18
+ - Package installation smoke test for the CLI, REST, GraphQL, OpenAPI, and auth.
19
+ - TypeScript consumer test against the installed package declarations.
20
+ - CI matrix for Node.js 22, 24, and 26 on Linux.
package/MIGRATION.md ADDED
@@ -0,0 +1,41 @@
1
+ # Migrating from 0.9.0 to 1.0.0-rc.2
2
+
3
+ Version 1.0 changes configuration and request syntax. Update the server configuration and client requests together. Back up any file database, auth records, and file metadata before changing the running server.
4
+
5
+ ## Configuration
6
+
7
+ Declare a storage mode and use `source` for each enabled component:
8
+
9
+ | 0.9.0 | 1.0.0-rc.2 |
10
+ |---|---|
11
+ | `database.path` | `storage: 'file'`, `database.source` |
12
+ | `database.data` | `storage: 'memory'`, `database.source` |
13
+ | `files.directory` | `files.source` in file mode |
14
+ | `files.data` | `files.source` in memory mode |
15
+ | `openapi.path` | `openapi.target` |
16
+
17
+ The `storage` mode applies to the database, schema, auth records, files, and package metadata. GraphQL and OpenAPI require a model schema; OpenAPI also requires `package.source`. The schema format has changed: define models under `models`, with a `collection`, fields, and one primary key per model. Use root `api` to enable REST, GraphQL, or both for the database; a model's optional `api` array can narrow that choice. Start with the [current schema example](examples/schema.json), then validate your existing records against it. The [configuration example](examples/server.config.js) shows all required paths.
18
+
19
+ ## CLI
20
+
21
+ Adding a `files`, `graphql`, or `openapi` section enables that feature. The old `--files`, `--openapi`, and `--openapi-only` flags are gone. Use `--generate` to export configured schemas and start the server, or `--generate-only` to export and exit. Each exported format needs a `target` path.
22
+
23
+ ## REST queries
24
+
25
+ REST now accepts a JSON `scope` query parameter. Replace `_where`, `_sort`, `_page`, `_perPage`, `_embed`, and simple field filters with `scope`. For example:
26
+
27
+ ```js
28
+ const scope = [
29
+ { id: true, title: true, publishers: [{ id: true, name: true }] },
30
+ { where: { title: { contains: 'Ardenia' } }, order: [{ field: 'title', direction: 'ASC' }], pager: { page: 1, pageSize: 10 } },
31
+ ];
32
+ const url = `/movies?${new URLSearchParams({ scope: JSON.stringify(scope) })}`;
33
+ ```
34
+
35
+ Without an explicit `scope`, the response contains scalar fields only. `"*": true` also selects only scalar fields that do not store relation keys. Select arrays, objects, relations, and relation keys explicitly. Related lists can have their own filters, order, and pagination. Review clients that expect embedded relations or relation keys in default responses.
36
+
37
+ ## Records and auth
38
+
39
+ Explicit models validate fields and relations more strictly than the 0.9 schemaless server. Existing records with undeclared fields or dangling direct relation keys may fail validation at startup or on write. Test the migrated database before replacing the production file.
40
+
41
+ Authentication is optional and enabled by an `auth` section. When enabled, creating records requires login; changing existing records requires ownership or administrator access. Record timestamps and soft deletion are configured in the model schema. The [README](README.md) describes the current behavior and API endpoints.
package/README.md CHANGED
@@ -2,17 +2,19 @@
2
2
 
3
3
  [Русский](README.ru.md)
4
4
 
5
+ [Release notes](CHANGELOG.md) · [Migration from 0.9.0](MIGRATION.md)
6
+
5
7
  A JSON mock server with REST, GraphQL, related records, file uploads and schema exports. Supports user login, owner and administrator permissions, record timestamps and soft deletion. Requires Node.js 22 or newer.
6
8
 
7
- **Breaking changes: 1.0.0-beta.2.** The REST `scope` wildcard selects only scalar fields that do not store relation keys. Arrays, objects, relations and their keys must be selected explicitly. With auth enabled, record permissions are available through the virtual `actions` field.
9
+ **Breaking changes in 1.0.0.** See the [migration guide](MIGRATION.md) when upgrading from 0.9.0. The REST `scope` wildcard selects only scalar fields that do not store relation keys. Arrays, objects, relations and their keys must be selected explicitly. With auth enabled, record permissions are available through the virtual `actions` field.
8
10
 
9
11
  ## Installation
10
12
 
11
13
  ```sh
12
- npm install @kollors/deep-json-server@beta
14
+ npm install @kollors/deep-json-server@rc
13
15
  ```
14
16
 
15
- To install a specific version, use `@1.0.0-beta.6`.
17
+ To install this release candidate, use `@1.0.0-rc.2`.
16
18
 
17
19
  ## Quick start
18
20
 
@@ -23,7 +25,7 @@ Create two files in the same directory.
23
25
  ```json
24
26
  {
25
27
  "users": [
26
- { "id": "1", "fullName": "Мира Волкова" }
28
+ { "id": "1", "fullName": "Mira Volkova" }
27
29
  ]
28
30
  }
29
31
  ```
@@ -44,7 +46,7 @@ Add a [model schema](#model-schema) to define relations and validation. See [que
44
46
 
45
47
  ## Configuration
46
48
 
47
- With `storage: 'file'`, all sources and the schema are paths. With `'memory'`, they are in-memory data. Modes cannot be mixed. The presence of `auth`, `files`, `graphql` and `openapi` enables those modules. `graphql: {}` and `openapi: {}` enable only the HTTP endpoints at their defaults; add `target` to export a schema.
49
+ With `storage: 'file'`, provide paths for every source and the schema. With `'memory'`, provide data directly. Use the same mode throughout the configuration. Add `auth` or `files` to enable those REST services. Add `graphql` to configure the GraphQL endpoint and `openapi` to serve the REST specification. `graphql: {}` and `openapi: {}` use default endpoint paths; add `target` to export a schema. GraphQL must also be enabled by root `api` in the model schema.
48
50
 
49
51
  ```js
50
52
  export default {
@@ -72,7 +74,7 @@ export default {
72
74
  | `graphql.target` | GraphQL SDL export destination |
73
75
  | `openapi.endpoint` | HTTP endpoint; default `/openapi.json` |
74
76
  | `openapi.target` | OpenAPI export destination |
75
- | `package.source` | Project `package.json`; required when `openapi` or `graphql` is configured |
77
+ | `package.source` | Project `package.json`; required when `openapi` is configured |
76
78
  | `server.host`, `server.port` | Defaults `127.0.0.1`, `4001`; CLI also reads `HOST`/`PORT` |
77
79
  | `server.pageSize`, `server.maxPageSize` | Defaults 10 and 100; default size is capped by the maximum |
78
80
  | `server.cors`, `server.logger` | Default `true`; logger also accepts Fastify logger options |
@@ -82,6 +84,36 @@ export default {
82
84
 
83
85
  Relative paths resolve from the configuration file directory, or from the working directory with `createServer(config)`. In-memory data, including the schema and package metadata, is copied. Port `0` lets the system choose an available port.
84
86
 
87
+ To expose the database only through GraphQL while keeping authentication and files as REST endpoints documented by OpenAPI, use:
88
+
89
+ ```js
90
+ export default {
91
+ storage: 'file',
92
+ database: { source: './database.json', schema: './schema.json' },
93
+ auth: { source: './users.json' },
94
+ files: { source: './uploads' },
95
+ graphql: {},
96
+ openapi: {},
97
+ package: { source: './package.json' },
98
+ };
99
+ ```
100
+
101
+ Set the root `api` in `schema.json`:
102
+
103
+ ```json
104
+ {
105
+ "api": ["graphql"],
106
+ "models": {
107
+ "Item": {
108
+ "collection": "items",
109
+ "fields": { "id": { "type": "string", "primary": true } }
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ Use `"api": ["rest"]` with `openapi: {}` for REST and its OpenAPI description, or `["rest", "graphql"]` with both sections for both database APIs. The `graphql` section is required exactly when the schema root includes `graphql`. OpenAPI describes database routes only when REST is enabled; authentication and file routes are included whenever their sections are configured.
116
+
85
117
  ### CLI
86
118
 
87
119
  | Flag | Action |
@@ -101,10 +133,7 @@ Examples: [database](examples/database.json), [model schema](examples/schema.jso
101
133
 
102
134
  ```json
103
135
  {
104
- "api": [
105
- "openapi",
106
- "graphql"
107
- ],
136
+ "api": ["rest", "graphql"],
108
137
  "models": {
109
138
  "Country": {
110
139
  "collection": "countries",
@@ -146,7 +175,11 @@ Examples: [database](examples/database.json), [model schema](examples/schema.jso
146
175
  }
147
176
  ```
148
177
 
149
- Model definitions belong in `models`. The schema root can define `timestamps` and `softDelete`; a model can override each setting. The `openapi` and `graphql` configuration sections enable the corresponding API. A model's `api` array only limits these enabled formats: `[]` excludes the model from GraphQL and OpenAPI while REST remains available. If no model enables a requested format, generation fails with a clear error. Related models must allow the same format. Model names must be valid identifiers; type and operation collisions cause errors. `and`, `or` and `not` are reserved filter names.
178
+ Model definitions belong in `models`. The schema root accepts `models`, `api`, `timestamps` and `softDelete`. Root `api` selects database routes. When omitted, it defaults to REST and also GraphQL if the server config has a `graphql` section. A model can override the global timestamp and soft-deletion settings. A model's optional `api` array can narrow access to `['rest']`, `['graphql']`, both, or `[]` to hide it from both. A model cannot enable an API absent from root `api`. OpenAPI includes models with REST enabled. GraphQL generation needs at least one GraphQL model; REST OpenAPI generation needs at least one REST model. On a GraphQL-only server, OpenAPI can still describe configured auth and file routes. Related models must allow the same API. Model names must be valid identifiers; type and operation collisions cause errors. `and`, `or` and `not` are reserved filter names.
179
+
180
+ For example, with root `api: ['rest', 'graphql']`, a model set to `api: ['rest']` has REST routes and OpenAPI paths but no GraphQL operations; a model set to `api: ['graphql']` has GraphQL operations but no REST routes or OpenAPI paths.
181
+
182
+ An excluded model remains part of the database schema and its stored records are still validated. Its `api` setting controls how clients can access it.
150
183
 
151
184
  | Capability | With schema | Without schema |
152
185
  |---|---|---|
@@ -159,7 +192,7 @@ Explicit schemas are strict: undeclared fields and collections are rejected, exc
159
192
 
160
193
  Schemaless REST generates an `id` and preserves arbitrary JSON fields. Newly inferred relations are available to subsequent reads and writes without restarting the server. Filters and individual field selections use identifier-style names. `scope=[{"*":true}]` returns top-level JSON scalars; arrays and objects must be selected by name. Fields with mixed value types can be read explicitly, but filtering, ordering and paging heterogeneous lists require an explicit schema.
161
194
 
162
- Each model requires `collection`, the database collection and REST path name, and `fields`, its field definitions. The model name (`User`) determines GraphQL type and operation names. `api` controls format availability; `timestamps` and `softDelete` override global settings for that model.
195
+ Each model requires `collection` (the database collection name, also used as its REST path when REST is enabled) and `fields` (field definitions). The model name (`User`) determines GraphQL type and operation names. `api` controls route availability; `timestamps` and `softDelete` override global settings for that model.
163
196
 
164
197
  ### Fields
165
198
 
@@ -225,37 +258,37 @@ Cascading deletion runs as one operation, including cyclic relations. A validati
225
258
  {
226
259
  "id": "1",
227
260
  "isArchived": false,
228
- "name": "Ардения"
261
+ "name": "Ardenia"
229
262
  },
230
263
  {
231
264
  "id": "2",
232
265
  "isArchived": false,
233
- "name": "Велория"
266
+ "name": "Veloria"
234
267
  }
235
268
  ],
236
269
  "genres": [
237
270
  {
238
271
  "id": "1",
239
272
  "isArchived": false,
240
- "name": "Криминал",
273
+ "name": "Crime",
241
274
  "parentIds": []
242
275
  },
243
276
  {
244
277
  "id": "2",
245
278
  "isArchived": false,
246
- "name": "Гангстер",
279
+ "name": "Gangster",
247
280
  "parentIds": ["1"]
248
281
  },
249
282
  {
250
283
  "id": "3",
251
284
  "isArchived": false,
252
- "name": "Драма",
285
+ "name": "Drama",
253
286
  "parentIds": []
254
287
  },
255
288
  {
256
289
  "id": "4",
257
290
  "isArchived": false,
258
- "name": "Комедия",
291
+ "name": "Comedy",
259
292
  "parentIds": []
260
293
  }
261
294
  ],
@@ -274,20 +307,20 @@ Cascading deletion runs as one operation, including cyclic relations. A validati
274
307
  }
275
308
  ],
276
309
  "coverSrc": "https://example.com/covers/shadows-of-ardenia.jpg",
277
- "description": "Наследница портового города раскрывает заговор двух соперничающих семей.",
310
+ "description": "An heiress in a port city uncovers a plot involving two rival families.",
278
311
  "id": "1",
279
312
  "isArchived": false,
280
313
  "publisherIds": ["2"],
281
- "title": "Тени Ардении"
314
+ "title": "Shadows of Ardenia"
282
315
  },
283
316
  {
284
317
  "actors": [],
285
318
  "coverSrc": "https://example.com/covers/northern-star.jpg",
286
- "description": "Ночной администратор старого отеля случайно становится участником поисков пропавшей картины.",
319
+ "description": "A night clerk at an old hotel gets drawn into the search for a missing painting.",
287
320
  "id": "2",
288
321
  "isArchived": false,
289
322
  "publisherIds": ["1"],
290
- "title": "Полночь в «Северной звезде»"
323
+ "title": "Midnight at the Northern Star"
291
324
  }
292
325
  ],
293
326
  "publishers": [
@@ -306,14 +339,14 @@ Cascading deletion runs as one operation, including cyclic relations. A validati
306
339
  {
307
340
  "bornAt": "1988-03-14",
308
341
  "countryId": "1",
309
- "fullName": "Мира Волкова",
342
+ "fullName": "Mira Volkova",
310
343
  "id": "1",
311
344
  "isArchived": false
312
345
  },
313
346
  {
314
347
  "bornAt": "1991-11-02",
315
348
  "countryId": "2",
316
- "fullName": "Леон Ветров",
349
+ "fullName": "Leon Vetrov",
317
350
  "id": "2",
318
351
  "isArchived": false
319
352
  }
@@ -361,7 +394,7 @@ Root `where` selects records from the main collection. `where` inside a relation
361
394
 
362
395
  ### REST
363
396
 
364
- `GET /` returns collection names: `{ "resources": ["users", "movies"] }`. Each collection has these routes:
397
+ When REST is enabled by root `api`, `GET /` lists only REST-enabled models: `{ "resources": ["users", "movies"] }`. A GraphQL-only server has no `GET /` database route. Each REST-enabled collection has these routes:
365
398
 
366
399
  | Method | Path | Operation |
367
400
  |---|---|---|
@@ -393,7 +426,7 @@ const scope = [
393
426
  ],
394
427
  },
395
428
  {
396
- where: { fullName: { contains: 'Мира' } },
429
+ where: { fullName: { contains: 'Mira' } },
397
430
  order: [{ field: 'fullName', direction: 'ASC' }],
398
431
  pager: { page: 1, pageSize: 20 },
399
432
  },
@@ -468,7 +501,7 @@ Use either the relation field or its storage key in an object, for example `genr
468
501
  }
469
502
  ```
470
503
 
471
- The server neither gives one field priority nor merges the values; the entire operation is rolled back. Relation fields accept objects only; use `genreIds` to change links without creating or updating related records. Reverse relations update the target key. If a target path crosses an array and the server cannot identify one element to attach, provide the array with the intended keys explicitly. Protected keys cannot be changed.
504
+ The server rejects both fields together and rolls back the operation. Relation fields accept objects only; use `genreIds` to change links without creating or updating related records. Reverse relations update the target key. If a target path crosses an array and the server cannot identify one element to attach, provide the array with the intended keys explicitly. Protected keys cannot be changed.
472
505
 
473
506
  All nested changes belong to the main record's transaction. A validation error, missing record or invalid response selection rolls back the entire operation. Updating a shared record affects every record linked to it.
474
507
 
@@ -489,7 +522,7 @@ mutation {
489
522
 
490
523
  ### GraphQL
491
524
 
492
- Set `database.schema` and add `graphql: {}` plus `package.source` to the configuration:
525
+ Set `database.schema`, include `graphql` in the schema's root `api`, and add `graphql: {}` to the configuration:
493
526
 
494
527
  ```sh
495
528
  npx deep-json-server server.config.js
@@ -500,7 +533,7 @@ Send requests to `/graphql` using POST with `Content-Type: application/json` and
500
533
  ```graphql
501
534
  query {
502
535
  userList(
503
- where: { fullName: { contains: "Мира" } }
536
+ where: { fullName: { contains: "Mira" } }
504
537
  order: [{ field: fullName, direction: ASC }]
505
538
  pager: { page: 1, pageSize: 20 }
506
539
  ) {
@@ -509,7 +542,7 @@ query {
509
542
  id
510
543
  fullName
511
544
  movies(
512
- where: { title: { contains: "Тени" } }
545
+ where: { title: { contains: "Shadows" } }
513
546
  order: [{ field: title, direction: ASC }]
514
547
  pager: { pageSize: 5 }
515
548
  ) {
@@ -529,7 +562,7 @@ Errors include `extensions.code`: `INVALID_INPUT`, `INVALID_QUERY`, `NOT_FOUND`,
529
562
 
530
563
  ## OpenAPI and schema exports
531
564
 
532
- Exports use OpenAPI 3.0.3. Add `openapi: {}`, `database.schema` and `package.source` to serve the specification at `/openapi.json`. Change the route with `openapi.endpoint`. OpenAPI `info.title`, `info.version` and optional `info.description` come from the configured `package.json`. Open the document in Swagger UI or import it into an API client.
565
+ Exports use OpenAPI 3.0.3. Add `openapi: {}`, `database.schema` and `package.source` to serve the specification at `/openapi.json`. Change the route with `openapi.endpoint`. Database paths appear only for REST-enabled models; a GraphQL-only database can still produce a document for configured auth and file routes. OpenAPI `info.title`, `info.version` and optional `info.description` come from the configured `package.json`. Open the document in Swagger UI or import it into an API client.
533
566
 
534
567
  Set output paths to save schemas:
535
568
 
@@ -548,7 +581,7 @@ npx deep-json-server server.config.js --generate-only
548
581
  npx deep-json-server server.config.js --generate
549
582
  ```
550
583
 
551
- `--generate-only` exports and exits; `--generate` starts the server after exporting. Configuration sections select the formats. Each selected format requires its own `target`. Missing sections, missing targets or generation errors fail the command before server startup.
584
+ `--generate-only` exports and exits; `--generate` starts the server after exporting. Configuration sections select the formats. Each selected format requires its own `target`. The OpenAPI HTTP endpoint returns JSON; file exports from `writeOpenapi()` and the CLI are YAML. Missing sections, missing targets or generation errors fail the command before server startup.
552
585
 
553
586
  Export does not open the database, user records or files. Every selected `target` is checked before writing and cannot overwrite the configuration, database, schema, users, counters or file metadata.
554
587
 
@@ -657,7 +690,7 @@ query {
657
690
 
658
691
  `actions` is available on root and related model records, including mutation results. It cannot be written, filtered or ordered. Plain embedded objects and auth user responses do not receive it.
659
692
 
660
- OpenAPI describes auth routes, optional Bearer authentication on record reads, required authentication on record changes and the `actions` response field. In Swagger UI, paste a token from login into **Authorize**. For schema exports, enable auth in the configuration and run `npx deep-json-server server.config.js --generate-only`; the users file is not read during generation. Auth methods are exposed through REST. GraphQL checks the same token when reading permissions or changing records. GraphQL and OpenAPI require `database.schema`.
693
+ When `openapi` is configured, its document describes auth routes, optional Bearer authentication on record reads, required authentication on record changes and the `actions` response field. In Swagger UI, paste a token from login into **Authorize**. For schema exports, enable auth in the configuration and run `npx deep-json-server server.config.js --generate-only`; the users file is not read during generation. Auth methods are exposed through REST. GraphQL checks the same token when reading permissions or changing records. GraphQL and OpenAPI require `database.schema`.
661
694
 
662
695
  ## Record dates, deletion and ownership
663
696
 
@@ -721,7 +754,7 @@ REST returns 401 for an invalid or missing token and 403 for insufficient permis
721
754
 
722
755
  ## Files
723
756
 
724
- Files are available through REST and documented in OpenAPI. Add storage to the configuration:
757
+ Files are available through REST and appear in the OpenAPI document when `openapi` is configured. Add storage to the configuration:
725
758
 
726
759
  ```js
727
760
  export default {
@@ -812,7 +845,9 @@ await server.listen();
812
845
 
813
846
  The `openapi()` and `graphql()` methods return schemas and require `database.schema`. `fastify()` returns the server instance for configuration and startup. The database and enabled services initialize on `ready()`, `listen()` or the first `inject()`; initialization errors stop startup.
814
847
 
815
- `createServer(config)` takes the same configuration object as the CLI. When `openapi` or `graphql` is configured, `package.source` is required. The `openapi()` and `graphql()` methods require their respective sections. They return schemas without writing files.
848
+ `createServer(config)` takes the same configuration object as the CLI. When `openapi` is configured, `package.source` is required. The `openapi()` and `graphql()` methods require their respective sections. They return schemas without writing files.
849
+
850
+ The returned Fastify instance accepts standard `listen()` options, including a Unix socket path. Calling `listen()` without options uses `server.host` and `server.port`.
816
851
 
817
852
  The root import `@kollors/deep-json-server` also provides these functions. Server adapters load when enabled. Generators can be used independently:
818
853
 
@@ -826,7 +861,7 @@ await writeOpenapi(document, './generated/openapi.yaml');
826
861
  await writeGraphql(sdl, './generated/schema.graphql');
827
862
  ```
828
863
 
829
- Standalone generators accept a schema path or object without a server configuration. The selected function supplies the default format; a model's `api` setting can restrict it. Timestamps and soft deletion come from the schema. `{ auth: true }` adds ownership and `actions` fields; OpenAPI also describes auth routes and token requirements. `hashPassword()` is available from the root package.
864
+ Standalone generators accept a schema path or object without a server configuration. If root `api` is omitted, `generateOpenapi()` defaults it to REST and `generateGraphql()` to GraphQL. Explicit root and model `api` values still apply; the selected format must have an enabled model. Timestamps and soft deletion come from the schema. `{ auth: true }` adds ownership and `actions` fields; OpenAPI also describes auth routes and token requirements. `hashPassword()` is available from the root package.
830
865
 
831
866
  `generateOpenapi()` requires `packagePath` and also accepts `host`, `port`, `pageSize` and `maxPageSize`. It reads OpenAPI metadata from that package. Pass a schema object instead of a path if preferred. Servers and generators use their own copy of the model. Pagination sizes must be positive integers; `pageSize` cannot exceed `maxPageSize`.
832
867
 
@@ -836,14 +871,14 @@ Updates run sequentially within one server instance and are validated on a copy
836
871
 
837
872
  ## Development
838
873
 
839
- Source modules: `rest`, `graphql`, `openapi`, `auth`, `files`, `cli` and `server`. Shared models, storage, queries and mutation rules live in `core`. `server` connects the modules; API generators load independently of the HTTP runtime.
874
+ The source code is organized into `rest`, `graphql`, `openapi`, `auth`, `files`, `cli` and `server`. Shared models, storage, queries and mutation rules live in `core`. The `server` module connects them; API generators load independently of the HTTP runtime.
840
875
 
841
876
  ```sh
842
877
  npm ci
843
878
  npm run verify
844
879
  ```
845
880
 
846
- The command checks types, code style, test coverage and installation from the package archive.
881
+ `npm run verify` checks types, code style, test coverage and installation from the package archive.
847
882
 
848
883
  To publish a prerelease, update the version in `package.json`, `package-lock.json` and `src/core/constants.ts`, then push the commit to `main`. GitHub Actions creates its `v<version>` tag and publishes through trusted publishing to the `alpha`, `beta` or `rc` channel. Stable versions publish to `latest` from an explicitly pushed version tag.
849
884