Skip to content

Commit 0e738b4

Browse files
committed
Update README.md
1 parent 3ee8140 commit 0e738b4

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
node_modules
22
bun.lockb
3+
.obsidian
4+
.vscode
5+
.idea

README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,65 @@
1+
An application for create custom response.
2+
3+
## Installation
4+
Firstly, clone this repository
5+
```
6+
git clone https://github.com/doannc2212/stub.git
17
```
8+
1. Run with bun
9+
```
10+
cd stub
211
bun install
312
bun run dev
413
```
5-
14+
2. Docker (todo)
15+
```
16+
docker compose up -d
17+
```
18+
Then,
619
```
720
open http://localhost:3000
821
```
9-
# stub
22+
23+
## How to use?
24+
Note that you must attack cookie `userId=${value}` for api to know which user need mock response
25+
26+
1. Create a new mock response
27+
Send a request to stub endpoint
28+
```json
29+
POST baseUrl/create
30+
Cookie: userId=john
31+
{
32+
// request method
33+
"method": "GET",
34+
// requset path, which place right after baseUrl/api/
35+
"path": "/sample",
36+
// response body
37+
"data": {
38+
"id": 1,
39+
"name": "John Doe"
40+
},
41+
// response status
42+
"status": 200
43+
}
44+
```
45+
46+
2. Clear mock response
47+
```json
48+
POST baseUrl/clear
49+
Cookie: userId=john
50+
```
51+
52+
3. Retrieve mock data
53+
Send request to `baseUrl/api/` + `path` which you create before
54+
*Request*:
55+
```JSON
56+
GET baseUrl/api/sample
57+
Cookie: userId=john
58+
```
59+
Response:
60+
```JSON
61+
{
62+
"id": 1,
63+
"name": "John Doe"
64+
}
65+
```

0 commit comments

Comments
 (0)