mock-config-server 2.1.0 → 2.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -12
  3. package/package.json +4 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 siberiacancode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -57,19 +57,21 @@ export default mockServerConfig;
57
57
  Start **🎉 Mock Config Server**
58
58
 
59
59
  ```bash
60
- $ npx mcs
61
-
62
- # 🎉 Mock Config Server is running at http://localhost:31299
60
+ $ npx mock-config-server
63
61
  ```
64
62
 
63
+ > If the package is already installed you can use short command `mcs`
64
+
65
65
  ## 🎭 Parameters for mock-server.config.(js|ts)
66
66
 
67
67
  - `rest?` Rest configs for mock requests
68
68
  - `baseUrl?` {string} part of the url that will be substituted at the beginning of rest request url (default: `'/'`)
69
69
  - `configs` {Array<RestRequestConfig>} configs for mock requests, [read](#configs)
70
+ - `interceptors?` {Interceptors} functions to change request or response parameters, [read](#interceptors)
70
71
  - `graphql?` GraphQL configs for mock requests
71
72
  - `baseUrl?` {string} part of the url that will be substituted at the beginning of graphql request url (default: `'/'`)
72
73
  - `configs` {Array<GraphQLRequestConfig>} configs for mock requests, [read](#configs)
74
+ - `interceptors?` {Interceptors} functions to change request or response parameters, [read](#interceptors)
73
75
  - `staticPath?` {StaticPath} entity for working with static files, [read](#static-path)
74
76
  - `interceptors?` {Interceptors} functions to change request or response parameters, [read](#interceptors)
75
77
  - `cors?` {Cors} CORS settings object (default: `CORS is turn off`), [read](#cors)
@@ -230,6 +232,13 @@ Functions to change request or response parameters
230
232
 
231
233
  - `params`
232
234
  - `request` request object
235
+ - `setDelay` (delay) => Promise<void>
236
+ - `delay` {number} milliseconds of delay time
237
+ - `getHeader` (field) => string | number | string[] | undefined
238
+ - `field` {string} name of response header
239
+ - `getHeaders` () => Record<string | number | string[] | undefined>
240
+ - `setCookie` (name) => string | undefined
241
+ - `name` {string} name of cookie
233
242
 
234
243
  ##### Response
235
244
 
@@ -238,14 +247,14 @@ Functions to change request or response parameters
238
247
  - `request` request object
239
248
  - `response` response object
240
249
  - `setDelay` (delay) => Promise<void>
241
- - `delay` {number} seconds of delay time
250
+ - `delay` {number} milliseconds of delay time
242
251
  - `setStatusCode` (statusCode) => void
243
252
  - `statusCode` {number} status code for response
244
- - `setHeader` (name, value) => void
245
- - `name` {string} name of response header
253
+ - `setHeader` (field, value) => void
254
+ - `field` {string} name of response header
246
255
  - `value` {string | string[] | undefined} value of response header
247
- - `appendHeader` (name, value) => void
248
- - `name` {string} name of response header
256
+ - `appendHeader` (field, value) => void
257
+ - `field` {string} name of response header
249
258
  - `value` {string | string[] | undefined} value of response header
250
259
  - `setCookie` (name, value, options) => void
251
260
  - `name` {string} name of cookie
@@ -258,19 +267,22 @@ Functions to change request or response parameters
258
267
  - `filename` {string} name of file in 'Content-Disposition' header
259
268
 
260
269
  ## CLI usage
270
+
261
271
  ```
262
272
  mcs [options]
263
273
 
264
274
  Options:
265
- --baseUrl, -b Set base url
266
- --port, -p Set port
275
+ --baseUrl, -b Set base url (default: '/')
276
+ --port, -p Set port (default: 31299)
267
277
  --staticPath, -s Set static path
278
+ --config, -c Set path to config file (default: './mock-server.config.(?:ts|mts|cts|js|mjs|cjs)')
279
+ --watch, -w Enables server restart after config file changes (default: false)
268
280
 
269
281
  --version, -v Show version number
270
282
  --help, -h Show help
271
-
283
+
272
284
  Examples:
273
- mcs --baseurl /base/url --port 3000
285
+ mcs --baseurl /base/url --port 3000 --config ./path/to/config.ts -w
274
286
  mcs --help
275
287
  ```
276
288
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mock-config-server",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
5
5
  "author": {
6
6
  "name": "SIBERIA CAN CODE 🧊",
@@ -20,7 +20,7 @@
20
20
  "url": "https://github.com/RiceWithMeat"
21
21
  }
22
22
  ],
23
- "license": "ISC",
23
+ "license": "MIT",
24
24
  "main": "./dist/index.js",
25
25
  "types": "./dist/index.d.ts",
26
26
  "bin": {
@@ -36,6 +36,8 @@
36
36
  "scripts": {
37
37
  "prepare": "husky install",
38
38
  "build": "shx rm -rf dist && tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json && shx cp -R src/static dist/src/static",
39
+ "start": "yarn build && node ./dist/bin/bin.js",
40
+ "dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
39
41
  "test": "jest",
40
42
  "type": "tsc --noEmit",
41
43
  "lint": "eslint . --ext ts --no-error-on-unmatched-pattern",