๐Ÿ“Œ json-server๋Š” json ํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ„๋‹จํ•œ ์‹œ๋ฎฌ๋ ˆ์ด์…˜์„ ์œ„ํ•œ REST API Mock server๋ฅผ ๊ตฌ์ถ•ํ•  ์ˆ˜ ์žˆ๋Š” ํˆด์ด๋‹ค.

๐Ÿšฉ ์„ค์น˜

npm install -g json-server

๐Ÿšฉ db.json ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ

{
  "posts": [
    { "id": 1, "title": "json-server", "author": "typicode" }
  ],
  "comments": [
    { "id": 1, "body": "some comment", "postId": 1 }
  ],
  "profile": { "name": "typicode" }
}

๐Ÿšฉ ์‹คํ–‰

json-server --watch db.json
๋˜๋Š”
**$ json-server --watch db.json --port 5000**

โ†’ ์›ํ•˜๋Š” port ๋„˜๋ฒ„๋ฅผ ์ž…๋ ฅํ•ด์ฃผ๋ฉด ํ•ด๋‹น ๋„˜๋ฒ„๋กœ ์‹คํ–‰

์ž…๋ ฅํ•˜์ง€ ์•Š์œผ๋ฉด 3000 port๋กœ ๋ฐ”๋กœ ์‹คํ–‰๋œ๋‹ค.