From c16d1cc6d61bee4930062e91301cc11649ab15b5 Mon Sep 17 00:00:00 2001 From: kev Date: Mon, 9 May 2016 11:21:31 +0800 Subject: [PATCH] update json-server --- json-server/README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/json-server/README.md b/json-server/README.md index 2f10499..4cb2156 100644 --- a/json-server/README.md +++ b/json-server/README.md @@ -5,4 +5,46 @@ json-server Get a full fake REST API with zero coding in less than 30 seconds (seriously) with [json-server][1]. +## docker-compose.yml + +```yaml +json-server: + image: vimagick/json-server + command: -w db.json + ports: + - "3000:3000" + volumes: + - ./db.json:/app/db.json + restart: always +``` + +## db.json + +```json +{ + "posts": [ + { "id": 1, "title": "json-server", "author": "typicode" } + ], + "comments": [ + { "id": 1, "body": "some comment", "postId": 1 } + ], + "profile": { "name": "typicode" } +} +``` + +## up and running + +```bash +docker-compose up -d + +pip install httpie + +http GET :3000/posts +http POST :3000/posts id:=2 title=hello author=world +http PUT :3000/posts/2 title=Hello author=World +http PATCH :3000/posts/2 title=HELLO +http DELETE :3000/posts/2 +http GET :3000/db +``` + [1]: https://github.com/typicode/json-server