Skip to content

juanpinheiro/mock-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MOCK SERVER

You can create a fake Restfull API of your mocks to improve your front-end development using only JSON.

It's just a Node.js app using Express.

This application fully supports the Node on Heroku article.

Deploy to Heroku

Deploying to Heroku

We gonna use Node on Heroku and mLab. You must have Heroku CLI installed.

$ heroku create # or heroku create project-name
$ heroku addons:create mongolab
$ git push heroku master
$ heroku open

How to use MOCK SERVER

Using Front-end Web Application

You can use the Front-end Web Application to manage your mock.

Mock Server Front

Using the API

Run in Postman

  • Header ContentType: application/json

  • POST /mock, save and update passing "_id" field.

        {
        "method": "GET",
        "route": "/hello",
        "use": 200,
        "timeout": 200,
        "responses":[
            {
                "code": 200,
                "data": {
                    "msg": "Success!"
                }
            },
            {
                "code": 500,
                "data": {
                    "msg": "Internal Server Error"
                }
            }
        ]
    }
  • GET /mocks, return all mocks

  • GET /mock/:id, ruturn a single mock by ID

  • DELETE /mock/:id, delete a mock by ID

Running Locally

You must have the following applications installed:

$ git clone https://github.com/juanpinheiro/mock-server.git # or clone your own fork
$ cd mock-server
$ npm install
$ npm start

Your app should now be running on localhost:3000.

Have fun!