Skip to content

funnyhcat-dotcom/api-mock-lite

Repository files navigation

api-mock-lite

Start a tiny local mock API server from a JSON file.

CI

Why

Frontend developers often need fake APIs before backend endpoints are ready. api-mock-lite starts a simple JSON API in one command.

Install

npm install -g api-mock-lite

Usage

api-mock-lite mock.json
api-mock-lite mock.json --port 3001
api-mock-lite mock.json --host 0.0.0.0
api-mock-lite mock.json --delay 300

mock.json

{
  "GET /users": [
    { "id": 1, "name": "Tom" }
  ],
  "POST /login": {
    "status": 201,
    "body": { "token": "fake-token" }
  }
}

Then visit:

curl http://127.0.0.1:3001/users

Features

  • GET/POST/PUT/PATCH/DELETE route keys
  • simple or advanced { status, headers, body } responses
  • JSON responses
  • CORS enabled
  • optional response delay
  • zero runtime dependencies

Demo

See docs/DEMO.md for a quick hands-on example.

Development

npm run check

License

MIT

About

Start a tiny local mock API server from JSON.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors