mockaton 7.5.2 → 7.5.3
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 +13 -0
- package/package.json +1 -1
- package/src/Mockaton.js +4 -4
package/README.md
CHANGED
|
@@ -150,6 +150,8 @@ export default function optionalName(request, response) {
|
|
|
150
150
|
}
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
If you need to serve a static `.js` file, put it in `Config.staticDir`.
|
|
154
|
+
|
|
153
155
|
|
|
154
156
|
## File Name Convention
|
|
155
157
|
|
|
@@ -203,6 +205,16 @@ api/foo/.GET.200.json
|
|
|
203
205
|
|
|
204
206
|
---
|
|
205
207
|
|
|
208
|
+
## `Config.staticDir`
|
|
209
|
+
Files under `Config.staticDir` don’t use the filename convention.
|
|
210
|
+
Also, they take precedence over the `GET` mocks in `Config.mockDir`.
|
|
211
|
+
|
|
212
|
+
For example, if you have two files for `GET /foo/bar.jpg`
|
|
213
|
+
```
|
|
214
|
+
my-static-dir/foo/bar.jpg
|
|
215
|
+
my-mocks-dir/foo/bar.jpg.GET.200.jpg // Unreacheable
|
|
216
|
+
```
|
|
217
|
+
|
|
206
218
|
|
|
207
219
|
## `Config.proxyFallback`
|
|
208
220
|
Lets you specify a target server for serving routes you don’t have mocks for.
|
|
@@ -360,3 +372,4 @@ await mockaton.reset()
|
|
|
360
372
|
## TODO
|
|
361
373
|
- Refactor Tests
|
|
362
374
|
- Dashboard. List `staticDir` and indicate if it’s overriding some mock.
|
|
375
|
+
- jsonc, json5
|
package/package.json
CHANGED
package/src/Mockaton.js
CHANGED
|
@@ -46,13 +46,13 @@ async function onRequest(req, response) {
|
|
|
46
46
|
if (isPreflight(req))
|
|
47
47
|
sendNoContent(response)
|
|
48
48
|
|
|
49
|
-
else if (method === 'GET' && apiGetRequests.has(url))
|
|
50
|
-
apiGetRequests.get(url)(req, response)
|
|
51
|
-
|
|
52
49
|
else if (method === 'PATCH' && apiPatchRequests.has(url))
|
|
53
50
|
await apiPatchRequests.get(url)(req, response)
|
|
54
51
|
|
|
55
|
-
else if (
|
|
52
|
+
else if (method === 'GET' && apiGetRequests.has(url))
|
|
53
|
+
apiGetRequests.get(url)(req, response)
|
|
54
|
+
|
|
55
|
+
else if (method === 'GET' && isStatic(req)) // TESTME
|
|
56
56
|
await dispatchStatic(req, response)
|
|
57
57
|
|
|
58
58
|
else
|