Sign inSign up

easypi/json-server

By easypi

Updated 11 days ago

Get a full fake REST API with zero coding in less than 30 seconds (seriously)

Image
Developer tools
0

373

easypi/json-server repository overview

json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously) with json-server.

docker-compose.yml

services:
  json-server:
    image: easypi/json-server
    command: -h 0.0.0.0 -p 3000 -s ./public db.json
    init: true
    ports:
      - "3000:3000"
    volumes:
      - ./data:/data
    restart: unless-stopped

:warning: init: true is required. read more

data/db.json

{
  "posts": [
    {
      "id": "1",
      "title": "a title",
      "views": 100
    },
    {
      "id": "2",
      "title": "another title",
      "views": 200
    }
  ],
  "comments": [
    {
      "id": "1",
      "text": "a comment about post 1",
      "postId": "1"
    },
    {
      "id": "2",
      "text": "another comment about post 1",
      "postId": "1"
    }
  ],
  "profile": {
    "name": "typicode"
  }
}

up and running

docker-compose up -d

pip install httpie

http GET :3000/posts
http POST :3000/posts id:=3 title=hello author=world
http PUT :3000/posts/3 title=Hello author=World
http PATCH :3000/posts/3 title=HELLO
http DELETE :3000/posts/3
http GET :3000/db

Tag summary

Content type

Image

Digest

sha256:6b35dac0b

Size

35.4 MB

Last updated

11 days ago

docker pull easypi/json-server