File tree Expand file tree Collapse file tree 2 files changed +61
-2
lines changed Expand file tree Collapse file tree 2 files changed +61
-2
lines changed Original file line number Diff line number Diff line change 11node_modules
22bun.lockb
3+ .obsidian
4+ .vscode
5+ .idea
Original file line number Diff line number Diff line change 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
211bun install
312bun run dev
413```
5-
14+ 2 . Docker (todo)
15+ ```
16+ docker compose up -d
17+ ```
18+ Then,
619```
720open 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+ ```
You can’t perform that action at this time.
0 commit comments