Mockup Serverとは
プロントエンドとバックエンドを同時に開発する場合、バックエンドのapiとデータ名などが合わない時が多いです。
でもMockup Serverを使用したら、Local環境で簡単にDirectoryとJsonをファイルを作成し、サーバー起動ができます。
作成した物をGitで管理したらフロントエンドとバックエンド開発者が幸せに開発ができます。
使用方法
- Mockupサーバー化ためのDirectoryを作成。
- 1番から生成したDirectoryの中にindex.json(成功)、error.Json(失敗)を作成。
- Mockup Server スタート!!
index.json
// response json
[
{
"id": "1", //dynamic api key ex) localhost/bla/:id
"name": "Sara",
"age": "13"
},
{
"id": "2",
"name": "teddy",
"age": "14"
}
]
setting.json
// setting header, cookies, api description etc
{
"header": {
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "123",
"ETag": "12345"
},
"cookies": [
{ //cookie1
"cookiekey": "cookieName",
"options": {
"maxAge": 30000
}
},
{ //cookie2
"hello": "hi",
"options": {
"maxAge": 10000
}
}
],
"dynamicRoute":"hello", // ex) localhost/bla/:hello
"description": "this API is holy shit" // api description
}
Set Cookies
API Description tooltip
CRUD (Create, Read, Update ,Delete)
// index.json
[
{
"id": "1",
"name": "Sara",
"age": "13"
},
{
"id": "2",
"name": "teddy",
"age": "14"
}
]
CRUD (Create, Read, Update ,Delete)
Post, Get
- http://localhost:9000/nice2/test if you send params object, and then add object in response data (POST)
//response data
[
{
"id": "1",
"name": "Sara",
"age": "13"
},
{
"id": "2",
"name": "teddy",
"age": "14"
}
]
//response data
[
{
"id": "1",
"name": "Sara",
"age": "13"
}
]
Put
//request data
{
"id": "3",
"name": "Sara",
"age": "13"
}
//response data
[
{
"id": "3",
"name": "Sara",
"age": "13"
},
{
"id": "2",
"name": "teddy",
"age": "14"
}
]
Delete
//response data
[
{
"id": "2",
"name": "teddy",
"age": "14"
}
]
DownLoad
- Mac, Windows: