#get|post|put|patch|delete(url): Create an endpoint at the specified URL. Can then be followed by each of the following, which can follow each other too e.g. get().query().body().status().body().creates.get() etc.

#proxy(url|options): The response should be a proxy of another URL. Currently, options accepts both url and headers properties. The headers property specifies the headers which should be sent in the request to the proxy URL

#delay(milliseconds): Set the number of milliseconds to delay the response by to mimic network of processing lag

#creates#get|post|put|patch|delete(url): Specify an endpoint to create after the first execution of this one. API is the same as above.

#extends#get|post|put|patch|delete(url): Specify an endpoint to modify after the first execution of this one. API is the same as above. The endpoints you extend are matched based on url and query. The status, body, delay and responseHeaders are the extendable bits. Keep in mind that keys will be replaced, and arrays will be added to.

By using Interfake's .serveStatic() method, you can serve some front-end HTML, JavaScript and CSS which uses the API you've created as the backend. Not only does this massively speed up development time by not having to have a real API, it serves as a great prototype for the real API, and avoids having to mock requests. This is my most common use for Interfake.

If you'd like to develop an API-driven mobile application you might not yet have a finished API available. This is a perfect example of where Interfake is useful. You can quickly mock up some dummy APIs and work on the mobile application. In parallel, perhaps another developer will be creating the real API, or you could create it later.

You can use Interfake to create dummy APIs which use data from your test setup with the HTTP method above, or by using a static set of test data. If you're writing your test suite using a NodeJS library, you can use the JavaScript API.

The HTTP API is particularly useful for developing iOS Applications which uses Automated tests written in JavaScript, or developing Node.js applications which rely on external APIs.

The example above creates a simple proxy against the URL https://api.github.com/repos/basicallydan/interfake/tags and will return whatever a public, non-authorized user will see. However, consider an endpoint which requires authorization.

interfake.get('/github-issues').proxy({

url:'https://api.github.com/repos/basicallydan/interfake/tags',

headers:{

'Authorization':'Token qoinfiu13jfcikwkhf1od091dj0'

}

});

This example uses an authorization token to authorize the request. This is one of the common use-cases. However, the first one will easily solve CORS issues, and any other headers apart from Authorization can be specified instead.

Interfake is a labour of love, created for front-end and mobile developers to increase their prototyping and development speeds. If you can contribute by getting through some issues, I would be very grateful. Please read more about how to contribute in the CONTRIBUTING.md document.

It's important that the tests all pass so we can keep this little badge green: