Sign inSign up

flaviostutz/json-server

By flaviostutz

•Updated over 6 years ago

Docker container for json-server - a fake REST API for devs

Image
0

5.6K

flaviostutz/json-server repository overview

⁠json-server

Docker container for https://github.com/typicode/json-server⁠ - a fake REST API for devs

This is useful for simulating a real REST server with a full REST interface.

You can define a list of COLLECTIONS that will be accepted in REST calls at http://localhost:3000/[COLLECTION⁠] in ENV parameters (see below).

After POST, data will be recorded to /data/db.json, so it can be persistent.

See more info at https://github.com/typicode/json-server⁠

⁠Usage

  • Create docker-compose.yml
version: '3.7'
services:
  json-server:
    image: flaviostutz/json-server
    ports:
      - "3000:3000"
    environment:
      - COLLECTIONS=cars,houses
  • Run docker-compose up

  • Post data to collection curl -X POST http://localhost:3000/cars -d '{"name":"great car", "type":"1", "year":"2001"}'

  • List data from collection curl http://localhost:3000/cars

⁠Tips

⁠ENVs

  • COLLECTIONS - comma separated list of accepted collections in REST API. ex: 'cars,person,events' will make curl -X POST http://localhost:3000/cars⁠ -d {"name":"Fusca"} acceptable

  • RESPONSE_DELAY_MS - time of delay in responses to simulate lag

Tag summary

Content type

Image

Digest

Size

44.1 MB

Last updated

over 6 years ago

docker pull flaviostutz/json-server