2.1.7 • Published 4 years ago

fakerio v2.1.7

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Faker - Simple Fake API Server

Build Status

Installation

bash -c "$(curl -sSL https://raw.githubusercontent.com/dotronglong/faker/master/install.sh)"

Getting Started

Create a folder mocks and put below content to file mocks/users.json

{
  "plugins": [
    {
      "name": "list",
      "args": {
        "count": 5,
        "item": {
          "id": "#random:int:min=1&max=1000#",
          "name": "#random:name#",
          "created_at": "#timestamp#",
          "updated_at": "#timestamp#"
        }
      }
    },
    {"name": "random"},
    {"name": "timestamp"}
  ],
  "request": {
    "method": "GET",
    "path": "/v1/users"
  },
  "response": {
    "body": []
  }
}

Next, run this command to start faker

fakerio -s ./mocks

It will parse source folder and start an application on port 3030

Use curl to test the result

curl http://localhost:3030/v1/users
[
  {
    "id": 105,
    "name": "Jesse Ortega",
    "created_at": 1581691318567,
    "updated_at": 1581691318567
  },
  {
    "id": 561,
    "name": "Steven Peterson",
    "created_at": 1581691318567,
    "updated_at": 1581691318567
  },
  {
    "id": 779,
    "name": "John Adams",
    "created_at": 1581691318567,
    "updated_at": 1581691318567
  },
  {
    "id": 768,
    "name": "Joseph Watson",
    "created_at": 1581691318567,
    "updated_at": 1581691318567
  },
  {
    "id": 196,
    "name": "David Howell",
    "created_at": 1581691318567,
    "updated_at": 1581691318567
  }
]

Links

2.1.6

4 years ago

2.1.7

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.5

4 years ago

2.1.2

4 years ago