@databehave/server 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/admin/ui.css +1 -2
- package/dist/admin/ui.js +102 -102
- package/dist/bin.js +33 -4
- package/dist/bin.js.map +1 -1
- package/dist/json-config.js +1 -1
- package/dist/json-config.js.map +1 -1
- package/package.json +29 -27
- package/docs/admin/error-mode.md +0 -14
- package/docs/admin/headers.md +0 -63
- package/docs/admin/index.md +0 -111
- package/docs/admin/overrides.md +0 -23
- package/docs/admin/rest-api.md +0 -90
- package/docs/admin/scenarios.md +0 -28
- package/docs/cli.md +0 -76
- package/docs/config/admin.md +0 -62
- package/docs/config/cors.md +0 -72
- package/docs/config/endpoints.md +0 -162
- package/docs/config/index.md +0 -107
- package/docs/config/log.md +0 -43
- package/docs/config/mock-mode.md +0 -84
- package/docs/config/openapi.md +0 -8
- package/docs/config/schema.md +0 -34
- package/docs/config/server.md +0 -32
- package/docs/config/validation.md +0 -161
- package/docs/design.md +0 -517
- package/docs/errors.md +0 -192
- package/docs/getting-started.md +0 -146
- package/docs/index.md +0 -23
- package/docs/openapi/auto-schema.md +0 -146
- package/docs/openapi/fallback.md +0 -242
- package/docs/openapi/keywords.md +0 -78
- package/docs/recipes.md +0 -258
- package/docs/stability.md +0 -118
- package/docs/troubleshooting.md +0 -191
package/docs/troubleshooting.md
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# Troubleshooting
|
|
2
|
-
|
|
3
|
-
Symptoms a first-time user is most likely to hit, with the cause and
|
|
4
|
-
the fix. For the full catalogue of error messages (verbatim, with
|
|
5
|
-
source citations) see [errors.md](./errors.md).
|
|
6
|
-
|
|
7
|
-
## `[@databehave/server] Auto-schema mode is enabled … but the data-generation engine is not installed`
|
|
8
|
-
|
|
9
|
-
**Cause.** Your `databehave.jsonc` sets `"schema": { "enabled": true }`
|
|
10
|
-
but the optional peer `@databehave/schema` is not resolvable from
|
|
11
|
-
the server's working directory.
|
|
12
|
-
|
|
13
|
-
**Fix.** Install the peer, set `"schema": { "enabled": false }`,
|
|
14
|
-
or remove the `schema` field entirely to fall back to the zero-dep
|
|
15
|
-
OAS-only generator:
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
npm i @databehave/schema
|
|
19
|
-
# or: pnpm add @databehave/schema
|
|
20
|
-
# or: yarn add @databehave/schema
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The native Node `Cannot find module` text is intentionally
|
|
24
|
-
suppressed — the install hint is the user-visible error. See
|
|
25
|
-
[openapi/auto-schema.md#missing-install-error](./openapi/auto-schema.md#missing-install-error)
|
|
26
|
-
and [errors.md](./errors.md) for the verbatim template.
|
|
27
|
-
|
|
28
|
-
## `EADDRINUSE: address already in use`
|
|
29
|
-
|
|
30
|
-
**Cause.** Another process already holds `server.port`.
|
|
31
|
-
|
|
32
|
-
**Fix.** Either stop the other process or change the port. The
|
|
33
|
-
config supports env-var interpolation, so a one-shot override is
|
|
34
|
-
cheap:
|
|
35
|
-
|
|
36
|
-
```jsonc
|
|
37
|
-
"server": { "host": "127.0.0.1", "port": "${MOCK_SERVER_PORT:8000}" }
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
MOCK_SERVER_PORT=8123 npx @databehave/server databehave.jsonc
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
See [config/server.md](./config/server.md).
|
|
45
|
-
|
|
46
|
-
## JSONC parse errors
|
|
47
|
-
|
|
48
|
-
**Symptom.** Boot fails with a `SyntaxError` or
|
|
49
|
-
`JSON Parse error: …` pointing at a position in `databehave.jsonc`.
|
|
50
|
-
|
|
51
|
-
**Cause.** The JSONC stripper accepts `// line`, `/* block */`, and
|
|
52
|
-
trailing commas — but the result must still be valid JSON. Common
|
|
53
|
-
sources: missing closing brace, smart quotes pasted from a doc
|
|
54
|
-
editor, an embedded TS expression where a value is expected.
|
|
55
|
-
|
|
56
|
-
**Fix.** Validate the file with any JSON linter after stripping
|
|
57
|
-
comments. Grammar reference:
|
|
58
|
-
[config/index.md#file-format](./config/index.md#file-format).
|
|
59
|
-
|
|
60
|
-
## `JSON-only spec loader. Convert YAML first…`
|
|
61
|
-
|
|
62
|
-
**Cause.** The `openapi:` field points at a `.yaml` / `.yml` file.
|
|
63
|
-
The loader is JSON-only by design (no YAML runtime dependency).
|
|
64
|
-
|
|
65
|
-
**Fix.** Convert once, then point at the JSON output:
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
yq -o=json openapi.yaml > openapi.json
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
See [openapi/fallback.md#input-format](./openapi/fallback.md).
|
|
72
|
-
|
|
73
|
-
## `failed to parse JSON OpenAPI document … Unexpected token …`
|
|
74
|
-
|
|
75
|
-
**Cause.** The file is JSON but not valid — common culprits are a
|
|
76
|
-
stray trailing comma (the OAS loader is strict JSON, unlike the
|
|
77
|
-
JSONC config), a leading byte order mark from a non-UTF-8 editor
|
|
78
|
-
(stripped automatically only if it's the very first byte), or a
|
|
79
|
-
bundler injecting metadata.
|
|
80
|
-
|
|
81
|
-
**Fix.** Run the file through `jq . openapi.json` to surface the
|
|
82
|
-
exact offset.
|
|
83
|
-
|
|
84
|
-
## `unsupported $ref` / `$ref not found`
|
|
85
|
-
|
|
86
|
-
**Cause.** The OAS document references a remote `$ref`
|
|
87
|
-
(`https://…`) or a `#/components/schemas/X` that does not exist.
|
|
88
|
-
Both the OAS-only generator and the auto-schema translator are
|
|
89
|
-
intra-document only — they will not fetch.
|
|
90
|
-
|
|
91
|
-
**Fix.** Inline the schema, or pre-bundle the spec with a tool
|
|
92
|
-
like `redocly bundle openapi.yaml`. See
|
|
93
|
-
[openapi/keywords.md](./openapi/keywords.md).
|
|
94
|
-
|
|
95
|
-
## `Unsupported JSON Schema keyword …` (auto-schema or validator)
|
|
96
|
-
|
|
97
|
-
**Cause.** The kit FAILS LOUD on JSON-Schema keywords it cannot
|
|
98
|
-
faithfully implement. Currently rejected:
|
|
99
|
-
|
|
100
|
-
`if`, `then`, `else`, `dependentSchemas`, `dependentRequired`,
|
|
101
|
-
`unevaluatedProperties`, `unevaluatedItems`, `contentEncoding`,
|
|
102
|
-
`contentMediaType`, `propertyNames`, `patternProperties`, and
|
|
103
|
-
remote (`http://…` / `https://…`) `$ref`.
|
|
104
|
-
|
|
105
|
-
**Fix.** Rewrite the schema using supported constructs, or restrict
|
|
106
|
-
the keyword to documents the kit does not translate (e.g. move it
|
|
107
|
-
to a response shape served by a hand-written `endpoints` handler,
|
|
108
|
-
which bypasses the translator). See
|
|
109
|
-
[errors.md](./errors.md) for the full unsupported-keyword catalogue.
|
|
110
|
-
|
|
111
|
-
## "My override didn't fire"
|
|
112
|
-
|
|
113
|
-
**Cause.** Override resolution priority is fixed:
|
|
114
|
-
`request header > exact route > path > global > mockMode > passthrough`.
|
|
115
|
-
A more-specific override wins. Stickies expire on
|
|
116
|
-
`expiresAt < Date.now()` and are otherwise persistent until
|
|
117
|
-
deleted.
|
|
118
|
-
|
|
119
|
-
**Fix.** Inspect `GET ${admin.path}/overrides` to see the
|
|
120
|
-
resolved set; look for a `x-mock-injected: <kind>:<source>` header
|
|
121
|
-
on the response — its presence proves an override fired and the
|
|
122
|
-
`source` field tells you which one. Reference:
|
|
123
|
-
[admin/overrides.md#sticky-override-resolution](./admin/overrides.md).
|
|
124
|
-
|
|
125
|
-
## CORS: my browser request is rejected even though the server is up
|
|
126
|
-
|
|
127
|
-
**Symptom.** The browser console reports
|
|
128
|
-
`No 'Access-Control-Allow-Origin' header is present`. Server logs
|
|
129
|
-
show the request arrived.
|
|
130
|
-
|
|
131
|
-
**Cause.** `cors.origin` is an allowlist (case-insensitive). When
|
|
132
|
-
the request `Origin` is not on the list the kit deliberately omits
|
|
133
|
-
the `Access-Control-Allow-Origin` response header — there is no
|
|
134
|
-
explicit reject; the browser does the rejection.
|
|
135
|
-
|
|
136
|
-
**Fix.** Add the origin to `cors.origin`, or set it to `"*"` for a
|
|
137
|
-
fully-open dev mock. See [config/cors.md](./config/cors.md).
|
|
138
|
-
|
|
139
|
-
## Validation rejection (`application/problem+json`)
|
|
140
|
-
|
|
141
|
-
**Symptom.** A request that the upstream accepts is rejected by
|
|
142
|
-
the kit with `400` / `401` / `413` / `415` / `422` and a
|
|
143
|
-
`content-type: application/problem+json` body.
|
|
144
|
-
|
|
145
|
-
**Cause.** `validation.request: true` is enabled and the request
|
|
146
|
-
fails one of the contract checks (auth, content-type, body size,
|
|
147
|
-
schema).
|
|
148
|
-
|
|
149
|
-
**Fix.** Read `body.violations` to locate the offending JSON-Pointer
|
|
150
|
-
path. To raise the body cap set
|
|
151
|
-
`validation.maxBodyBytes` (default `102400` / 100 KB). Full
|
|
152
|
-
contract: [config/validation.md](./config/validation.md).
|
|
153
|
-
|
|
154
|
-
## CLI: `unknown option(s)` / silent exit `2`
|
|
155
|
-
|
|
156
|
-
**Cause.** `@databehave/server` accepts only `--open` and `-h` /
|
|
157
|
-
`--help`. Any other flag is rejected and the process exits `2`
|
|
158
|
-
(bad usage). Missing positional `<config>` exits `2` for the same
|
|
159
|
-
reason.
|
|
160
|
-
|
|
161
|
-
**Fix.** Move custom flags into `databehave.jsonc` or
|
|
162
|
-
`createServer({...})`. See [cli.md](./cli.md).
|
|
163
|
-
|
|
164
|
-
## "Admin mode refuses to bind to `0.0.0.0`"
|
|
165
|
-
|
|
166
|
-
**Cause.** When `admin.enabled === true` the server enforces
|
|
167
|
-
loopback binding at `listen()` time unless `admin.bind: "any"`
|
|
168
|
-
is explicitly set. The admin panel exposes destructive operations
|
|
169
|
-
(override CRUD, scenarios, optionally `x-mock-destroy`); shipping
|
|
170
|
-
it on a routable interface is rejected as a footgun.
|
|
171
|
-
|
|
172
|
-
**Fix.** Bind to `127.0.0.1` / `::1` / `localhost`, or set
|
|
173
|
-
`admin.bind: "any"` to confirm intent. See
|
|
174
|
-
[admin/index.md#security-notes](./admin/index.md#security-notes).
|
|
175
|
-
|
|
176
|
-
## "I changed `seed` and the responses didn't change"
|
|
177
|
-
|
|
178
|
-
**Cause.** `schema.seed: "stable"` derives the per-request seed
|
|
179
|
-
from `${METHOD} ${path}|${sortedQuery}|${sortedParams}` — the value
|
|
180
|
-
of the `seed` field itself is irrelevant in stable mode. To rotate
|
|
181
|
-
the seed, switch to a number or to `"random"`.
|
|
182
|
-
|
|
183
|
-
**Fix.** Pick the mode you want:
|
|
184
|
-
|
|
185
|
-
```jsonc
|
|
186
|
-
"schema": { "enabled": true, "seed": 42 } // fixed; same body forever
|
|
187
|
-
"schema": { "enabled": true, "seed": "stable" } // default; varies per route+input
|
|
188
|
-
"schema": { "enabled": true, "seed": "random" } // fresh every request
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
See [openapi/auto-schema.md](./openapi/auto-schema.md).
|