mockaton 8.16.5 → 8.16.6
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 +21 -8
- package/package.json +1 -1
- package/src/Dashboard.css +38 -4
- package/src/Dashboard.js +16 -1
package/README.md
CHANGED
|
@@ -65,8 +65,8 @@ api/videos.GET.<b>500</b>.txt # Internal Server Error
|
|
|
65
65
|
## Scraping mocks from your Backend
|
|
66
66
|
|
|
67
67
|
### Option 1: Browser Extension
|
|
68
|
-
This [
|
|
69
|
-
lets you download
|
|
68
|
+
This [browser extension](https://github.com/ericfortis/download-http-requests-browser-ext)
|
|
69
|
+
lets you download all the HTTP responses following the filename convention.
|
|
70
70
|
|
|
71
71
|
### Option 2: Fallback to Your Backend
|
|
72
72
|
This option could be a bit elaborate if your backend uses third-party auth,
|
|
@@ -232,8 +232,17 @@ export default function listColors() {
|
|
|
232
232
|
```
|
|
233
233
|
</details>
|
|
234
234
|
|
|
235
|
-
**What if I need to serve a static .js?**
|
|
236
|
-
|
|
235
|
+
**What if I need to serve a static .js or .ts?**
|
|
236
|
+
|
|
237
|
+
**Option A:** Put it in your `config.staticDir` without the filename extension convention (i.e., no `.GET.200.js`)
|
|
238
|
+
|
|
239
|
+
**Option B:** Read it and return it. For example:
|
|
240
|
+
```js
|
|
241
|
+
export default function (_, response) {
|
|
242
|
+
response.setHeader('Content-Type', 'application/javascript')
|
|
243
|
+
return readFileSync('./some-dir/foo.js', 'utf8')
|
|
244
|
+
}
|
|
245
|
+
```
|
|
237
246
|
|
|
238
247
|
<br/>
|
|
239
248
|
|
|
@@ -337,10 +346,6 @@ api/foo/bar.GET.200.json
|
|
|
337
346
|
This is the only required field. The directory must exist.
|
|
338
347
|
|
|
339
348
|
### `staticDir?: string`
|
|
340
|
-
- Use Case 1: If you have a bunch of static assets you don’t want to add `.GET.200.ext`
|
|
341
|
-
- Use Case 2: For a standalone demo server. For example,
|
|
342
|
-
build your frontend bundle, and serve it from Mockaton.
|
|
343
|
-
|
|
344
349
|
Files under `config.staticDir` don’t use the filename convention, and
|
|
345
350
|
they take precedence over corresponding `GET` mocks in `config.mocksDir`.
|
|
346
351
|
For example, if you have two files for `GET /foo/bar.jpg`
|
|
@@ -350,6 +355,14 @@ my-static-dir<b>/foo/bar.jpg</b>
|
|
|
350
355
|
my-mocks-dir<b>/foo/bar.jpg</b>.GET.200.jpg // Unreachable
|
|
351
356
|
</pre>
|
|
352
357
|
|
|
358
|
+
This `config.staticDir` is not actually needed besides serving partial content
|
|
359
|
+
(e.g., videos). At any rate, it’s convenient for serving 200 GET requests without
|
|
360
|
+
having to add the filename extension convention (i.e., no `.GET.200.ext`).
|
|
361
|
+
For example, for using Mockaton as a standalone demo server. For that, you
|
|
362
|
+
can build your frontend bundle and put its built assets in this folder.
|
|
363
|
+
|
|
364
|
+
<br/>
|
|
365
|
+
|
|
353
366
|
### `ignore?: RegExp`
|
|
354
367
|
Defaults to `/(\.DS_Store|~)$/`
|
|
355
368
|
|
package/package.json
CHANGED
package/src/Dashboard.css
CHANGED
|
@@ -506,10 +506,8 @@ table {
|
|
|
506
506
|
|
|
507
507
|
.SpinnerClock {
|
|
508
508
|
display: flex;
|
|
509
|
-
width:
|
|
510
|
-
|
|
511
|
-
margin-top: 92px;
|
|
512
|
-
justify-self: center;
|
|
509
|
+
width: 48px;
|
|
510
|
+
margin-top: 6px;
|
|
513
511
|
fill: none;
|
|
514
512
|
stroke: var(--colorSecondaryAction);
|
|
515
513
|
stroke-width: 2px;
|
|
@@ -539,6 +537,42 @@ table {
|
|
|
539
537
|
filter: saturate(0);
|
|
540
538
|
}
|
|
541
539
|
|
|
540
|
+
.ErrorToast {
|
|
541
|
+
position: fixed;
|
|
542
|
+
bottom: 12px;
|
|
543
|
+
left: 12px;
|
|
544
|
+
z-index: 9999;
|
|
545
|
+
cursor: pointer;
|
|
546
|
+
background: var(--colorRed);
|
|
547
|
+
color: white;
|
|
548
|
+
padding: 12px 16px;
|
|
549
|
+
border-radius: var(--radius);
|
|
550
|
+
box-shadow: var(--boxShadow1);
|
|
551
|
+
opacity: 0;
|
|
552
|
+
transform: translateY(20px);
|
|
553
|
+
animation: _kfToastIn 240ms forwards;
|
|
554
|
+
|
|
555
|
+
&:hover {
|
|
556
|
+
&::after {
|
|
557
|
+
top: 0;
|
|
558
|
+
left: calc(100% - 6px);
|
|
559
|
+
position: absolute;
|
|
560
|
+
content: '×';
|
|
561
|
+
vertical-align: middle;
|
|
562
|
+
padding: 12px;
|
|
563
|
+
border-radius: var(--radius);
|
|
564
|
+
background: black;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
@keyframes _kfToastIn {
|
|
570
|
+
to {
|
|
571
|
+
opacity: 1;
|
|
572
|
+
transform: translateY(0);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
542
576
|
|
|
543
577
|
/*
|
|
544
578
|
* Prism
|
package/src/Dashboard.js
CHANGED
|
@@ -39,6 +39,7 @@ const Strings = {
|
|
|
39
39
|
const CSS = {
|
|
40
40
|
BulkSelector: 'BulkSelector',
|
|
41
41
|
DelayToggler: 'DelayToggler',
|
|
42
|
+
ErrorToast: 'ErrorToast',
|
|
42
43
|
FallbackBackend: 'FallbackBackend',
|
|
43
44
|
Field: 'Field',
|
|
44
45
|
GlobalDelayField: 'GlobalDelayField',
|
|
@@ -592,10 +593,24 @@ function mockSelectorFor(method, urlMask) {
|
|
|
592
593
|
|
|
593
594
|
function onError(error) {
|
|
594
595
|
if (error?.message === 'Failed to fetch')
|
|
595
|
-
|
|
596
|
+
showErrorToast('Looks like the Mockaton server is not running')
|
|
596
597
|
console.error(error)
|
|
597
598
|
}
|
|
598
599
|
|
|
600
|
+
function showErrorToast(msg) {
|
|
601
|
+
document.getElementsByClassName(CSS.ErrorToast)[0]?.remove()
|
|
602
|
+
document.body.appendChild(
|
|
603
|
+
r('div', {
|
|
604
|
+
className: CSS.ErrorToast,
|
|
605
|
+
onClick() {
|
|
606
|
+
const toast = this
|
|
607
|
+
document.startViewTransition(() => {
|
|
608
|
+
toast.remove()
|
|
609
|
+
})
|
|
610
|
+
}
|
|
611
|
+
}, msg))
|
|
612
|
+
}
|
|
613
|
+
|
|
599
614
|
function TimerIcon() {
|
|
600
615
|
return (
|
|
601
616
|
s('svg', { viewBox: '0 0 24 24' },
|