Skip to content

πŸš€ A dev server that mocks your API endpoints with autogenerated data

Notifications You must be signed in to change notification settings

vitkarpov/grampa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Grampa Simpson

πŸš€ A simple development server which mocks data for you.

Examples

Let the next file be mock-server.js:

import { Mock, server } from "grampa";

server.get('/users', () => {
  return new Array(5).fill(0).map({
    "first_name": Mock.name(),
    "second_name": Mock.name(),
    "birth": Mock.date(),
    "avatar": Mock.img({ w: 200, h: 200 })
  });
});
server.start();

Run it with Node.js:

$ node mock-server.js
  Server is running on http://127.0.0.1/

Make a request to get a list of users:

$ http http://127.0.0.1/users

[
  {
    "first_name": "Bret",
    "second_name": "Viktor",
    "birth": "19/09/1965",
    "avatar": "http://127.0.0.1/img/200x200.jpg"
  },
  {
    "first_name": "Albert",
    "second_name": "Einstein",
    "birth": "01/01/2011",
    "avatar": "http://127.0.0.1/img/200x200.jpg"
  },
  {
    "first_name": "David",
    "second_name": "Hilbert",
    "birth": "12/07/1981",
    "avatar": "http://127.0.0.1/img/200x200.jpg"
  },
  {
    "first_name": "Alan",
    "second_name": "Turing",
    "birth": "11/02/1989",
    "avatar": "http://127.0.0.1/img/200x200.jpg"
  },
  {
    "first_name": "Bjarne",
    "second_name": "Stroustrup",
    "birth": "08/04/1973",
    "avatar": "http://127.0.0.1/img/200x200.jpg"
  }
]

πŸ’ͺ Profit!

About

πŸš€ A dev server that mocks your API endpoints with autogenerated data

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published