mockaton 8.17.0 → 8.18.1

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 CHANGED
@@ -550,7 +550,7 @@ Defaults to `true`. When `true`, these are the default options:
550
550
  ```js
551
551
  config.corsOrigins = ['*']
552
552
  config.corsMethods = require('node:http').METHODS
553
- config.corsHeaders = ['content-type']
553
+ config.corsHeaders = ['content-type', 'authorization']
554
554
  config.corsCredentials = true
555
555
  config.corsMaxAge = 0 // seconds to cache the preflight req
556
556
  config.corsExposedHeaders = [] // headers you need to access in client-side JS
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "8.17.0",
5
+ "version": "8.18.1",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
@@ -26,5 +26,10 @@
26
26
  "open": "^10.0.0",
27
27
  "pixaton": ">=1.1.1",
28
28
  "puppeteer": ">=24.1.1"
29
+ },
30
+ "dependencies": {
31
+ "@vitejs/plugin-react": "5.0.1",
32
+ "mockaton": "8.18.0",
33
+ "vite": "7.1.3"
29
34
  }
30
35
  }
package/src/Dashboard.css CHANGED
@@ -7,7 +7,6 @@
7
7
  :root {
8
8
  --color4xxBackground: #ffedd1;
9
9
  --colorAccent: #0068c1;
10
- --colorAccentAlt: #068185;
11
10
  --colorBackground: #fff;
12
11
  --colorComboBoxHeaderBackground: #fff;
13
12
  --colorComboBoxBackground: #eee;
@@ -124,14 +123,13 @@ header {
124
123
  display: flex;
125
124
  flex-wrap: wrap;
126
125
  align-items: flex-end;
127
- gap: 10px;
126
+ gap: 16px 10px;
128
127
 
129
- @media (max-width: 860px) {
130
- max-width: 500px;
128
+ @media (max-width: 890px) {
129
+ max-width: 400px;
131
130
  }
132
131
  }
133
132
 
134
-
135
133
  img {
136
134
  width: 130px;
137
135
  align-self: center;
@@ -233,6 +231,21 @@ header {
233
231
  color: white;
234
232
  }
235
233
  }
234
+
235
+ .Help {
236
+ min-width: 24px;
237
+ align-self: center;
238
+ margin-left: auto;
239
+ fill: var(--colorSecondaryAction);
240
+
241
+ &:hover {
242
+ fill: var(--colorAccent);
243
+ }
244
+
245
+ @media (max-width: 590px) {
246
+ display: none;
247
+ }
248
+ }
236
249
  }
237
250
 
238
251
 
@@ -476,7 +489,8 @@ table {
476
489
  .StaticFilesList {
477
490
  a {
478
491
  display: inline-block;
479
- padding: 6px 0;
492
+ padding: 8px 0;
493
+ margin-left: 4px;
480
494
  border-radius: var(--radius);
481
495
  color: var(--colorAccent);
482
496
  text-decoration: none;
@@ -506,11 +520,12 @@ table {
506
520
 
507
521
  .SpinnerClock {
508
522
  display: flex;
509
- width: 48px;
510
- margin-top: 6px;
523
+ width: 64px;
524
+ margin: auto;
525
+ margin-top: 64px;
511
526
  fill: none;
512
527
  stroke: var(--colorSecondaryAction);
513
- stroke-width: 2px;
528
+ stroke-width: 1px;
514
529
 
515
530
  .HourHand,
516
531
  .MinuteHand {
@@ -519,7 +534,7 @@ table {
519
534
  animation: _kfRotate 9s linear infinite
520
535
  }
521
536
  .MinuteHand {
522
- animation-duration: .75s;
537
+ animation-duration: 1s;
523
538
  }
524
539
  }
525
540
  @keyframes _kfRotate {
package/src/Dashboard.js CHANGED
@@ -22,6 +22,7 @@ const Strings = {
22
22
  fallback_server: 'Fallback Backend',
23
23
  fallback_server_error: '⛔ Fallback Backend Error',
24
24
  fallback_server_placeholder: 'Type Server Address',
25
+ fetching: 'Fetching…',
25
26
  got: 'Got',
26
27
  internal_server_error: 'Internal Server Error',
27
28
  no_mocks_found: 'No mocks found',
@@ -32,7 +33,7 @@ const Strings = {
32
33
  proxy_toggler: 'Proxy Toggler',
33
34
  reset: 'Reset',
34
35
  save_proxied: 'Save Mocks',
35
- static_get: 'Static GET',
36
+ static_get: 'Static Folder GET',
36
37
  title: 'Mockaton'
37
38
  }
38
39
 
@@ -43,6 +44,7 @@ const CSS = {
43
44
  FallbackBackend: 'FallbackBackend',
44
45
  Field: 'Field',
45
46
  GlobalDelayField: 'GlobalDelayField',
47
+ Help: 'Help',
46
48
  InternalServerErrorToggler: 'InternalServerErrorToggler',
47
49
  MainLeftSide: 'leftSide',
48
50
  MainRightSide: 'rightSide',
@@ -115,7 +117,13 @@ function Header({ cookies, comments, delay, fallbackAddress, collectProxied }) {
115
117
  r(BulkSelector, { comments }),
116
118
  r(GlobalDelayField, { delay }),
117
119
  r(ProxyFallbackField, { fallbackAddress, collectProxied }),
118
- r(ResetButton))))
120
+ r(ResetButton)),
121
+ r('a', {
122
+ className: CSS.Help,
123
+ href: 'https://github.com/ericfortis/mockaton',
124
+ target: '_blank',
125
+ rel: 'noopener noreferrer'
126
+ }, r(HelpIcon))))
119
127
  }
120
128
 
121
129
  function Logo() {
@@ -535,7 +543,8 @@ function PayloadViewerTitleWhenProxied({ mime, status, statusText, gatewayIsBad
535
543
  }
536
544
 
537
545
  async function previewMock(method, urlMask, href) {
538
- const timer = setTimeout(renderSpinner, 180)
546
+ const timer = setTimeout(renderSpinner, 80)
547
+ payloadViewerTitleRef.current.replaceChildren(r('span', null, Strings.fetching))
539
548
  const response = await fetch(href, { method })
540
549
  clearTimeout(timer)
541
550
  await updatePayloadViewer(method, urlMask, response)
@@ -627,6 +636,11 @@ function CloudIcon() {
627
636
  s('path', { d: 'm6.1 9.1c2.8 0 5 2.3 5 5' })))
628
637
  }
629
638
 
639
+ function HelpIcon() {
640
+ return (
641
+ s('svg', { viewBox: '0 0 24 24' },
642
+ s('path', { d: 'M11 18h2v-2h-2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4' })))
643
+ }
630
644
 
631
645
  /**
632
646
  * # Poll UI Sync Version
package/src/Filename.js CHANGED
@@ -47,10 +47,10 @@ function validateFilename(file) {
47
47
  export function parseFilename(file) {
48
48
  const tokens = file.replace(reComments, '').split('.')
49
49
  return {
50
- urlMask: '/' + removeTrailingSlash(tokens.slice(0, -3).join('.')),
51
- method: tokens.at(-3),
52
- status: Number(tokens.at(-2)),
53
- ext: tokens.at(-1)
50
+ ext: tokens.pop(),
51
+ status: Number(tokens.pop()),
52
+ method: tokens.pop(),
53
+ urlMask: '/' + removeTrailingSlash(tokens.join('.'))
54
54
  }
55
55
  }
56
56
 
package/src/config.js CHANGED
@@ -42,7 +42,7 @@ const schema = {
42
42
  corsAllowed: [true, is(Boolean)],
43
43
  corsOrigins: [['*'], validateCorsAllowedOrigins],
44
44
  corsMethods: [SUPPORTED_METHODS, validateCorsAllowedMethods],
45
- corsHeaders: [['content-type'], Array.isArray],
45
+ corsHeaders: [['content-type', 'authorization'], Array.isArray],
46
46
  corsExposedHeaders: [[], Array.isArray],
47
47
  corsCredentials: [true, is(Boolean)],
48
48
  corsMaxAge: [0, is(Number)],
@@ -61,7 +61,7 @@ for (const [k, [defaultVal, validator]] of Object.entries(schema)) {
61
61
  /** @type {Config} */
62
62
  export const config = Object.seal(defaults)
63
63
 
64
- /** @type {Record<keyof Config, (val: unknown) => boolean>} */
64
+ /** @type {Record<keyof Config, (val: unknown) => val is Config[keyof Config]>} */
65
65
  export const ConfigValidator = Object.freeze(validators)
66
66
 
67
67