mockaton 8.2.6 → 8.2.7
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 +6 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,10 +124,14 @@ export default [
|
|
|
124
124
|
**Option B:** Function
|
|
125
125
|
|
|
126
126
|
Think of this as an HTTP handler. You can read or write to a
|
|
127
|
-
database, or pull data from a backend.
|
|
127
|
+
database, or pull data from a backend. Also, you can modify the
|
|
128
|
+
response object, e.g. for changing the status code and mime.
|
|
128
129
|
|
|
129
130
|
Don’t call `response.end()`, just return a `string | Buffer | Uint8Array`.
|
|
130
131
|
|
|
132
|
+
If you need to serve a static `.js` file, put it in your
|
|
133
|
+
`Config.staticDir` without the mock filename convention.
|
|
134
|
+
|
|
131
135
|
```js
|
|
132
136
|
export default function requestCounter(request, response) {
|
|
133
137
|
globalThis.myDatabase ??= { count: 0 }
|
|
@@ -138,11 +142,8 @@ export default function requestCounter(request, response) {
|
|
|
138
142
|
}
|
|
139
143
|
```
|
|
140
144
|
|
|
141
|
-
|
|
142
|
-
`Config.staticDir` without the mock filename convention.
|
|
143
|
-
|
|
145
|
+
This example will echo the request body concatenated with another fixture.
|
|
144
146
|
```js
|
|
145
|
-
// This example will echo the request body concatenated with another fixture.
|
|
146
147
|
// api/color.POST.201.js
|
|
147
148
|
|
|
148
149
|
import colors from './colors.json' with { type: 'json' }
|
package/package.json
CHANGED