Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alonronin/rest-mock

Mock REST api middleware for express
https://github.com/alonronin/rest-mock

Last synced: 24 days ago
JSON representation

Mock REST api middleware for express

Awesome Lists containing this project

README

        

# rest-mock

> A REST api middleware for express to mock API requests with full CRUD operations.

`npm i rest-mock --save`

Usage:

```javascript
var Mock = require('rest-mock');
var express = require('express');
var bodyParser = require('body-parser');

var app = express();
var mock = new Mock();

mock.resource('/config', { development: true });
mock.collection('/ips', [{ip: '192.1.1.1'}, {ip: '192.1.1.2'}, {ip: '192.1.1.3'}]);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.use('/api', mock.middleware());

app.listen(3000);
```

You have an example and tests.