restful-dummy-server 1.0.3 → 1.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 +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,32 +8,40 @@ npm install -g restful-dummy-server
|
|
|
8
8
|
### CLI options
|
|
9
9
|
|
|
10
10
|
#### 1. port
|
|
11
|
+
```js
|
|
11
12
|
"scripts": {
|
|
12
13
|
"start": "restful-dummy-server -port 4000"
|
|
13
14
|
}
|
|
15
|
+
```
|
|
14
16
|
|
|
15
17
|
This will start restful dummy server on port 4000
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
#### 2. host
|
|
19
21
|
You can also mention host.
|
|
22
|
+
```js
|
|
20
23
|
"scripts": {
|
|
21
24
|
"start": "restful-dummy-server -port 4000 -host xx.xx.xx.xx"
|
|
22
25
|
}
|
|
26
|
+
```
|
|
23
27
|
|
|
24
28
|
#### 3. static
|
|
29
|
+
```js
|
|
25
30
|
"scripts": {
|
|
26
31
|
"start": "restful-dummy-server -port 4000 -static ./data"
|
|
27
32
|
}
|
|
33
|
+
```
|
|
28
34
|
|
|
29
35
|
**static** is used to know the relative path of a folder where all statics files are hosted. Which then would be used by Dummy server to download files against the rest api dowbloaded request.
|
|
30
36
|
Here this folder is **data**.
|
|
31
37
|
|
|
32
38
|
|
|
33
39
|
#### 4. config
|
|
40
|
+
```js
|
|
34
41
|
"scripts": {
|
|
35
42
|
"start": "restful-dummy-server -port 4000 -static ./data -config ./test"
|
|
36
43
|
}
|
|
44
|
+
```
|
|
37
45
|
|
|
38
46
|
**config** is used to know the relative path of a folder which are having dummy request response instruction files in **.json** extensions only.
|
|
39
47
|
|
|
@@ -44,6 +52,7 @@ Note -
|
|
|
44
52
|
Example 1-
|
|
45
53
|
**test/config.json**
|
|
46
54
|
|
|
55
|
+
```js
|
|
47
56
|
[{
|
|
48
57
|
"request": {
|
|
49
58
|
"url": "/get/message",
|
|
@@ -54,6 +63,7 @@ Example 1-
|
|
|
54
63
|
"body": "Hello Dummy Server"
|
|
55
64
|
}
|
|
56
65
|
}]
|
|
66
|
+
```
|
|
57
67
|
|
|
58
68
|
In this case if you hit http://localhost:5000/get/message then you will get **Hello Dummy Server** as response.
|
|
59
69
|
|
|
@@ -61,6 +71,7 @@ In this case if you hit http://localhost:5000/get/message then you will get **He
|
|
|
61
71
|
Example 2-
|
|
62
72
|
**test/config.json**
|
|
63
73
|
|
|
74
|
+
```js
|
|
64
75
|
[{
|
|
65
76
|
"request": {
|
|
66
77
|
"url": "/get/:message",
|
|
@@ -71,6 +82,7 @@ Example 2-
|
|
|
71
82
|
"body": { "message": "Hello Dummy Server" }
|
|
72
83
|
}
|
|
73
84
|
}]
|
|
85
|
+
```
|
|
74
86
|
|
|
75
87
|
In this case if you hit http://localhost:5000/get/test or http://localhost:5000/get/msg etc. then you will get **{ "message": "Hello Dummy Server" }** as response.
|
|
76
88
|
|
|
@@ -78,6 +90,7 @@ In this case if you hit http://localhost:5000/get/test or http://localhost:5000/
|
|
|
78
90
|
Example 3-
|
|
79
91
|
**test/config.json**
|
|
80
92
|
|
|
93
|
+
```js
|
|
81
94
|
[{
|
|
82
95
|
"request": {
|
|
83
96
|
"url": "/get/png/*.*",
|
|
@@ -90,6 +103,7 @@ Example 3-
|
|
|
90
103
|
"body": "./test.png"
|
|
91
104
|
}
|
|
92
105
|
}]
|
|
106
|
+
```
|
|
93
107
|
|
|
94
108
|
In this case if you hit http://localhost:5000/get/png/abc.png or http://localhost:5000/get/png/msg.png etc. then **test.png** will be downloaded as response.
|
|
95
109
|
|
|
@@ -97,6 +111,7 @@ In this case if you hit http://localhost:5000/get/png/abc.png or http://localhos
|
|
|
97
111
|
Example 4-
|
|
98
112
|
**test/config.json**
|
|
99
113
|
|
|
114
|
+
```js
|
|
100
115
|
[{
|
|
101
116
|
"request": {
|
|
102
117
|
"url": "/get/**/*.*",
|
|
@@ -109,6 +124,7 @@ Example 4-
|
|
|
109
124
|
"body": "./test.png"
|
|
110
125
|
}
|
|
111
126
|
}]
|
|
127
|
+
```
|
|
112
128
|
|
|
113
129
|
In this case if you hit http://localhost:5000/get/png/abc.png or http://localhost:5000/get/png/png2/msg.jpeg etc. then **test.png** will be downloaded as response.
|
|
114
130
|
|
|
@@ -116,6 +132,7 @@ In this case if you hit http://localhost:5000/get/png/abc.png or http://localhos
|
|
|
116
132
|
Example 5-
|
|
117
133
|
**test/config.json**
|
|
118
134
|
|
|
135
|
+
```js
|
|
119
136
|
[{
|
|
120
137
|
"request": {
|
|
121
138
|
"url": "/get/**/*.png",
|
|
@@ -128,6 +145,7 @@ Example 5-
|
|
|
128
145
|
"body": "./test.png"
|
|
129
146
|
}
|
|
130
147
|
}]
|
|
148
|
+
```
|
|
131
149
|
|
|
132
150
|
In this case if you hit http://localhost:5000/get/png/abc.png or http://localhost:5000/get/png/png2/msg.png etc. then **test.png** will be downloaded as response.
|
|
133
151
|
|
|
@@ -135,6 +153,7 @@ In this case if you hit http://localhost:5000/get/png/abc.png or http://localhos
|
|
|
135
153
|
Example 6-
|
|
136
154
|
**test/config.json**
|
|
137
155
|
|
|
156
|
+
```js
|
|
138
157
|
[{
|
|
139
158
|
"request": {
|
|
140
159
|
"url": "/get/**/*.png",
|
|
@@ -148,14 +167,17 @@ Example 6-
|
|
|
148
167
|
"delay": 2000
|
|
149
168
|
}
|
|
150
169
|
}]
|
|
170
|
+
```
|
|
151
171
|
|
|
152
172
|
Above **delay** is the special attribute which would cause Dummy server to respond in 2000 milliseconds.
|
|
153
173
|
|
|
154
174
|
|
|
155
175
|
#### 5. proxy
|
|
176
|
+
```js
|
|
156
177
|
"scripts": {
|
|
157
178
|
"start": "restful-dummy-server -port 4000 -static ./data -config ./test -proxy localhost:2000"
|
|
158
179
|
}
|
|
180
|
+
```
|
|
159
181
|
|
|
160
182
|
If **proxy** is provided then Dummy server will redirect the request to the proxy server if there is no matching record found.
|
|
161
183
|
|