mockaton 0.10.5 → 0.10.7
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/_usage_example.js +3 -3
- package/package.json +1 -1
- package/src/Dashboard.js +10 -10
package/_usage_example.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { join } from 'node:path'
|
|
4
4
|
import { Mockaton, jwtCookie } from './index.js' // from 'mockaton'
|
|
5
5
|
|
|
6
6
|
Mockaton({
|
|
7
7
|
port: 2345,
|
|
8
|
-
mocksDir:
|
|
9
|
-
staticDir:
|
|
8
|
+
mocksDir: join(import.meta.dirname, 'sample-mocks'),
|
|
9
|
+
staticDir: join(import.meta.dirname, 'sample-static'),
|
|
10
10
|
cookies: {
|
|
11
11
|
'My Admin User': 'my-cookie=1;Path=/;SameSite=strict',
|
|
12
12
|
'My Normal User': 'my-cookie=0;Path=/;SameSite=strict',
|
package/package.json
CHANGED
package/src/Dashboard.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Route } from '../Route.js'
|
|
2
|
-
import {
|
|
2
|
+
import { API, DF } from '../ApiConstants.js'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const Strings = {
|
|
@@ -42,9 +42,9 @@ const refPayloadFile = useRef()
|
|
|
42
42
|
|
|
43
43
|
function init() {
|
|
44
44
|
Promise.all([
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
API.mocks,
|
|
46
|
+
API.cookies,
|
|
47
|
+
API.comments
|
|
48
48
|
].map(api => fetch(api).then(res => res.ok && res.json())))
|
|
49
49
|
.then(App)
|
|
50
50
|
.catch(console.error)
|
|
@@ -85,7 +85,7 @@ function ResetButton() {
|
|
|
85
85
|
return (
|
|
86
86
|
r('button', {
|
|
87
87
|
onClick() {
|
|
88
|
-
fetch(
|
|
88
|
+
fetch(API.reset, { method: 'PATCH' })
|
|
89
89
|
.then(init)
|
|
90
90
|
.catch(console.error)
|
|
91
91
|
}
|
|
@@ -101,7 +101,7 @@ function CookieSelector({ list }) {
|
|
|
101
101
|
autocomplete: 'off',
|
|
102
102
|
disabled: list.length <= 1,
|
|
103
103
|
onChange() {
|
|
104
|
-
fetch(
|
|
104
|
+
fetch(API.cookies, {
|
|
105
105
|
method: 'PATCH',
|
|
106
106
|
body: JSON.stringify({ [DF.currentCookieKey]: this.value })
|
|
107
107
|
})
|
|
@@ -122,7 +122,7 @@ function BulkSelector({ comments }) {
|
|
|
122
122
|
autocomplete: 'off',
|
|
123
123
|
disabled: comments.length <= 1,
|
|
124
124
|
onChange() {
|
|
125
|
-
fetch(
|
|
125
|
+
fetch(API.bulkSelect, {
|
|
126
126
|
method: 'PATCH',
|
|
127
127
|
body: JSON.stringify({ [DF.comment]: this.value })
|
|
128
128
|
})
|
|
@@ -200,7 +200,7 @@ function MockSelector({ items, selected }) {
|
|
|
200
200
|
this.style.fontWeight = this.value === this.options[0].value // default is selected
|
|
201
201
|
? 'normal'
|
|
202
202
|
: 'bold'
|
|
203
|
-
fetch(
|
|
203
|
+
fetch(API.edit, {
|
|
204
204
|
method: 'PATCH',
|
|
205
205
|
body: JSON.stringify({ [DF.file]: this.value })
|
|
206
206
|
}).then(() => {
|
|
@@ -227,7 +227,7 @@ function DelayToggler({ name, checked }) {
|
|
|
227
227
|
name,
|
|
228
228
|
checked,
|
|
229
229
|
onChange(event) {
|
|
230
|
-
fetch(
|
|
230
|
+
fetch(API.edit, {
|
|
231
231
|
method: 'PATCH',
|
|
232
232
|
body: JSON.stringify({
|
|
233
233
|
[DF.file]: this.name,
|
|
@@ -272,7 +272,7 @@ function TransformSelector({ items, selected }) {
|
|
|
272
272
|
className: className(selected === items[0]),
|
|
273
273
|
autocomplete: 'off',
|
|
274
274
|
onChange() {
|
|
275
|
-
fetch(
|
|
275
|
+
fetch(API.transform, {
|
|
276
276
|
method: 'PATCH',
|
|
277
277
|
body: JSON.stringify({ [DF.file]: this.value })
|
|
278
278
|
}).then(() => {
|