mockaton 11.1.4 → 11.2.0
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/Makefile +1 -1
- package/package.json +1 -1
- package/src/Dashboard.css +20 -10
- package/src/Dashboard.js +18 -14
- package/src/DashboardStore.js +3 -0
- package/src/MockDispatcher.js +0 -3
- package/src/Mockaton.js +3 -1
- package/src/config.js +2 -0
package/Makefile
CHANGED
package/package.json
CHANGED
package/src/Dashboard.css
CHANGED
|
@@ -235,6 +235,9 @@ header {
|
|
|
235
235
|
margin: 0;
|
|
236
236
|
margin-right: 4px;
|
|
237
237
|
}
|
|
238
|
+
input:enabled + span {
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
}
|
|
238
241
|
input:disabled + span {
|
|
239
242
|
opacity: 0.8;
|
|
240
243
|
}
|
|
@@ -287,23 +290,30 @@ header {
|
|
|
287
290
|
top: 62px;
|
|
288
291
|
right: 10px;
|
|
289
292
|
left: auto;
|
|
290
|
-
padding: 20px;
|
|
291
293
|
border: 1px solid var(--colorSecondaryActionBorder);
|
|
292
|
-
text-align: left;
|
|
293
294
|
color: var(--colorText);
|
|
294
295
|
border-radius: var(--radius);
|
|
295
296
|
box-shadow: var(--boxShadow1);
|
|
296
297
|
background: var(--colorHeaderBackground);
|
|
297
298
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
299
|
+
> div {
|
|
300
|
+
display: inline-flex;
|
|
301
|
+
flex-direction: column;
|
|
302
|
+
padding: 20px;
|
|
303
|
+
cursor: auto;
|
|
304
|
+
gap: 12px;
|
|
305
|
+
text-align: left;
|
|
301
306
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
+
a {
|
|
308
|
+
color: var(--colorAccent);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.GroupByMethod {
|
|
312
|
+
display: flex;
|
|
313
|
+
align-items: center;
|
|
314
|
+
gap: 6px;
|
|
315
|
+
cursor: pointer;
|
|
316
|
+
}
|
|
307
317
|
}
|
|
308
318
|
}
|
|
309
319
|
|
package/src/Dashboard.js
CHANGED
|
@@ -250,20 +250,24 @@ function SettingsMenu(id) {
|
|
|
250
250
|
}
|
|
251
251
|
},
|
|
252
252
|
|
|
253
|
-
r('
|
|
254
|
-
r('
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
253
|
+
r('div', null,
|
|
254
|
+
r('label', className(CSS.GroupByMethod),
|
|
255
|
+
r('input', {
|
|
256
|
+
ref: firstInputRef,
|
|
257
|
+
type: 'checkbox',
|
|
258
|
+
checked: store.groupByMethod,
|
|
259
|
+
onChange: store.toggleGroupByMethod
|
|
260
|
+
}),
|
|
261
|
+
r('span', null, t`Group by Method`)),
|
|
262
|
+
|
|
263
|
+
r('a', {
|
|
264
|
+
href: 'https://github.com/ericfortis/mockaton',
|
|
265
|
+
target: '_blank',
|
|
266
|
+
rel: 'noopener noreferrer'
|
|
267
|
+
}, t`Documentation`),
|
|
261
268
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
target: '_blank',
|
|
265
|
-
rel: 'noopener noreferrer'
|
|
266
|
-
}, t`Documentation`)))
|
|
269
|
+
r('p', null, `v${store.mockatonVersion}`)
|
|
270
|
+
)))
|
|
267
271
|
}
|
|
268
272
|
|
|
269
273
|
|
|
@@ -648,7 +652,7 @@ async function updatePayloadViewer(proxied, file, response) {
|
|
|
648
652
|
}))
|
|
649
653
|
else {
|
|
650
654
|
const body = await response.text() || t`/* Empty Response Body */`
|
|
651
|
-
if (mime === 'application/json')
|
|
655
|
+
if (mime === 'application/json')
|
|
652
656
|
payloadViewerCodeRef.elem.replaceChildren(SyntaxJSON(body))
|
|
653
657
|
else if (isXML(mime))
|
|
654
658
|
payloadViewerCodeRef.elem.replaceChildren(SyntaxXML(body))
|
package/src/DashboardStore.js
CHANGED
|
@@ -26,10 +26,13 @@ export const store = {
|
|
|
26
26
|
|
|
27
27
|
getSyncVersion: api.getSyncVersion,
|
|
28
28
|
|
|
29
|
+
mockatonVersion: '',
|
|
30
|
+
|
|
29
31
|
async fetchState() {
|
|
30
32
|
try {
|
|
31
33
|
const response = await api.getState()
|
|
32
34
|
if (!response.ok) throw response
|
|
35
|
+
store.mockatonVersion = response.headers.get('server').split(' ').pop()
|
|
33
36
|
Object.assign(store, await response.json())
|
|
34
37
|
store.render()
|
|
35
38
|
}
|
package/src/MockDispatcher.js
CHANGED
|
@@ -31,9 +31,6 @@ export async function dispatchMock(req, response) {
|
|
|
31
31
|
if (cookie.getCurrent())
|
|
32
32
|
response.setHeader('Set-Cookie', cookie.getCurrent())
|
|
33
33
|
|
|
34
|
-
for (let i = 0; i < config.extraHeaders.length; i += 2) // TESTME
|
|
35
|
-
response.setHeader(config.extraHeaders[i], config.extraHeaders[i + 1])
|
|
36
|
-
|
|
37
34
|
response.statusCode = broker.auto500 ? 500 : broker.status // TESTME plugins can change it
|
|
38
35
|
const { mime, body } = broker.auto500
|
|
39
36
|
? { mime: '', body: '' }
|
package/src/Mockaton.js
CHANGED
|
@@ -41,7 +41,9 @@ export function Mockaton(options) {
|
|
|
41
41
|
|
|
42
42
|
async function onRequest(req, response) {
|
|
43
43
|
response.on('error', logger.warn)
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < config.extraHeaders.length; i += 2)
|
|
46
|
+
response.setHeader(config.extraHeaders[i], config.extraHeaders[i + 1])
|
|
45
47
|
|
|
46
48
|
const url = req.url || ''
|
|
47
49
|
|
package/src/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolve } from 'node:path'
|
|
2
|
+
import pkgJSON from '../package.json' with { type: 'json' }
|
|
2
3
|
|
|
3
4
|
import { logger } from './utils/logger.js'
|
|
4
5
|
import { isDirectory } from './utils/fs.js'
|
|
@@ -81,6 +82,7 @@ export function setup(options) {
|
|
|
81
82
|
Object.assign(config, options)
|
|
82
83
|
validate(config, ConfigValidator)
|
|
83
84
|
logger.setLevel(config.logLevel)
|
|
85
|
+
config.extraHeaders.push('Server', `Mockaton ${pkgJSON.version}`)
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
|