mockaton 8.0.3 → 8.0.4

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
@@ -15,7 +15,7 @@ can be used for downloading a TAR of your XHR requests following that convention
15
15
 
16
16
  ## Getting Started Demo
17
17
  - Checkout this repo
18
- - `npm install tsx`
18
+ - `npm install tsx` (optional)
19
19
  - `npm run demo:ts`
20
20
  which will open the following dashboard
21
21
  - Explore the [sample-mocks/](./sample-mocks) directory
@@ -47,7 +47,7 @@ _Reset_ button is for registering newly added, removed, or renamed mocks.
47
47
  - Similarly, it allows for checking out long-lived branches that have old API contracts
48
48
 
49
49
  ## Motivation
50
- - Avoids having to spin up and maintain hefty or complex backends when developing UIs.
50
+ - Avoids spinning up and maintaining hefty backends when developing UIs.
51
51
  - For a deterministic and comprehensive backend state. For example, having all the possible
52
52
  state variants of a collection helps for spotting inadvertent bugs.
53
53
 
@@ -177,7 +177,7 @@ but since that’s part of the query string, it’s ignored anyway.
177
177
 
178
178
 
179
179
  ### Index-like route
180
- For instance, let's say you have `api/foo/bar`, and
180
+ For instance, lets say you have `api/foo/bar`, and
181
181
  `api/foo`. For the latter you have two options:
182
182
 
183
183
  **Option A.** Place it outside the directory:
@@ -207,11 +207,6 @@ Defaults to `0`, which means auto-assigned
207
207
  Defaults to `/(\.DS_Store|~)$/`
208
208
 
209
209
 
210
- ### `proxyFallback?: string`
211
- Lets you specify a target server for serving routes you don’t have mocks for.
212
- For example, `Config.proxyFallback = 'http://example.com:8080'`
213
-
214
-
215
210
  ### `delay?: number` 🕓
216
211
  The clock icon next to the mock selector is a checkbox for delaying a
217
212
  particular response. They are handy for testing spinners.
@@ -219,6 +214,11 @@ particular response. They are handy for testing spinners.
219
214
  The delay is globally configurable via `Config.delay = 1200` (milliseconds).
220
215
 
221
216
 
217
+ ### `proxyFallback?: string`
218
+ Lets you specify a target server for serving routes you don’t have mocks for.
219
+ For example, `Config.proxyFallback = 'http://example.com:8080'`
220
+
221
+
222
222
  ### `staticDir?: string`
223
223
  Files under `Config.staticDir` don’t use the filename convention.
224
224
  Also, they take precedence over the `GET` mocks in `Config.mockDir`.
@@ -305,7 +305,7 @@ import { jsToJsonPlugin } from 'mockaton'
305
305
 
306
306
  Config.plugins = [
307
307
  [/\.(js|ts)$/, jsToJsonPlugin], // Default
308
- [/\.yaml$/, yamlToJsonPlugin],
308
+ [/\.yml$/, yamlToJsonPlugin],
309
309
  [/foo\.GET\.200\.txt$/, capitalizePlugin], // e.g. GET /api/foo would be capitalized
310
310
  ]
311
311
 
@@ -328,7 +328,7 @@ function capitalizePlugin(filePath) {
328
328
  ### `corsAllowed?: boolean`
329
329
  Defaults to `corsAllowed = false`
330
330
 
331
- When `corsAllowed === true`, these are the default options:
331
+ When `Config.corsAllowed === true`, these are the default options:
332
332
  ```js
333
333
  Config.corsOrigins = ['*']
334
334
  Config.corsMethods = ['GET', 'PUT', 'DELETE', 'POST', 'PATCH', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT']
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "A deterministic server-side for developing and testing frontend clients",
4
4
  "type": "module",
5
- "version": "8.0.3",
5
+ "version": "8.0.4",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
@@ -6,7 +6,7 @@
6
6
  <link rel="icon" href="data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m235 33.7v202c0 9.19-5.81 14-17.4 14-11.6 0-17.4-4.83-17.4-14v-151c-0.115-4.49-6.72-5.88-8.46-0.87l-48.3 155c-2.22 7.01-7.72 10.1-16 9.9-3.63-0.191-7.01-1.14-9.66-2.89-2.89-1.72-4.83-4.34-5.57-7.72-11.1-37-22.6-74.3-34.1-111-4.34-14-8.95-31.4-14-48.3-1.82-4.83-8.16-5.32-8.46 1.16v156c0 9.19-5.81 14-17.4 14-11.6 0-17.4-4.83-17.4-14v-207c0-5.74 2.62-13.2 9.39-16.3 7.5-3.14 15-4.05 21.8-3.8 3.14 0 6.03 0.686 8.95 1.46 3.14 0.797 6.03 1.98 8.7 3.63 2.65 1.38 5.32 3.14 7.5 5.57 2.22 2.22 3.87 4.83 5.07 7.72l45.8 157c4.63-15.9 32.4-117 33.3-121 4.12-13.8 7.72-26.5 10.9-38.7 1.16-2.65 2.89-5.32 5.07-7.5 2.15-2.15 4.58-4.12 7.5-5.32 2.65-1.57 5.57-2.89 8.46-3.63 3.14-0.797 9.44-0.988 12.1-0.988 11.6 1.07 29.4 9.14 29.4 27z' fill='%23808080'/%3E%3C/svg%3E">
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1">
8
8
  <meta name="description" content="Mock Server for developing UIs">
9
- <title>Mock Server</title>
9
+ <title>Mockaton</title>
10
10
  </head>
11
11
  <body>
12
12
  <script src="/Dashboard.js" type="module"></script>
package/src/Dashboard.js CHANGED
@@ -6,16 +6,17 @@ import { DEFAULT_500_COMMENT } from '/ApiConstants.js'
6
6
  const Strings = {
7
7
  allow_cors: 'Allow CORS',
8
8
  bulk_select_by_comment: 'Bulk Select by Comment',
9
+ bulk_select_by_comment_disabled_title: 'No mock files have comments, which are anything within parentheses on the filename.',
9
10
  click_link_to_preview: 'Click a link to preview it',
10
11
  cookie: 'Cookie',
12
+ cookie_disabled_title: 'No cookies specified in Config.cookies',
11
13
  delay: 'Delay',
12
14
  empty_response_body: '/* Empty Response Body */',
13
15
  internal_server_error: 'Internal Server Error',
14
16
  mock: 'Mock',
15
17
  reset: 'Reset',
16
18
  select_one: 'Select One',
17
- static: 'Static',
18
- title: 'Mockaton'
19
+ static: 'Static'
19
20
  }
20
21
 
21
22
  const CSS = {
@@ -59,7 +60,6 @@ function App([brokersByMethod, cookies, comments, corsAllowed, staticFiles]) {
59
60
  }
60
61
 
61
62
  function DevPanel(brokersByMethod, cookies, comments, corsAllowed, staticFiles) {
62
- document.title = Strings.title
63
63
  return (
64
64
  r('div', null,
65
65
  r('menu', null,
@@ -79,12 +79,14 @@ function DevPanel(brokersByMethod, cookies, comments, corsAllowed, staticFiles)
79
79
  }
80
80
 
81
81
  function CookieSelector({ list }) {
82
+ const disabled = list.length <= 1
82
83
  return (
83
84
  r('label', null,
84
85
  r('span', null, Strings.cookie),
85
86
  r('select', {
86
87
  autocomplete: 'off',
87
- disabled: list.length <= 1,
88
+ disabled,
89
+ title: disabled ? Strings.cookie_disabled_title : '',
88
90
  onChange() {
89
91
  mockaton.selectCookie(this.value)
90
92
  .catch(console.error)
@@ -107,6 +109,7 @@ function BulkSelector({ comments }) {
107
109
  r('select', {
108
110
  autocomplete: 'off',
109
111
  disabled,
112
+ title: disabled ? Strings.bulk_select_by_comment_disabled_title : '',
110
113
  onChange() {
111
114
  mockaton.bulkSelectByComment(this.value)
112
115
  .then(init)