HUB
Sign inSign up

besutome/json-server

By besutome

•Updated almost 10 years ago

REST API mock for json.

Image
0

350

besutome/json-server repository overview

⁠json-server

https://github.com/typicode/json-server⁠

⁠Usage

$ docker run -d \
 -p 8080:80 \
 -v `pwd`:/data/ \
  besutome/json-server

http://localhost:80⁠

  • -d will run a detached instance in the background
  • -p {OutsidePort}:80 will bind the webserver to the given outside port
  • -v {AbsolutePathToJsonFile}:/data/db.json should be passed to mount the given JSON file into the container
  • besutome/json-server the name of this docker image

⁠Example

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

⁠Generate random data

module.exports = function() {
  var data = { users: [] }
  // Create 1000 users
  for (var i = 0; i < 1000; i++) {
    data.users.push({ id: i, name: 'user' + i })
  }
  return data
}
Tag summary
Recent tags
Content type
Image
Digest
Size
21.4 MB
Last updated
almost 10 years ago
docker pull besutome/json-server:latest