API-Monkey
Middleware for test simulations with multi layered Express APIs.
Delay requests to specific API Endpoints and return custom Error codes.
Usage
Add API-Monkey to your project
npm install api-monkey --save-dev
Use API-Monkey in your express applications
const express = ; const apiMonkey = ; const app = ; app; app; app;
Then add information about which API Endpoints you want to delay/error in the header of your requests.
const request = ; request
Options
Request Headers
Delay requests to /test/:id
request ...
Get Error on a request (default Error statuscode is 500)
headers: 'monkey_get_test': 'none/true'
Get custom Errorcode on a request
headers: 'monkey_get_test': 'none/404'
Get delayed Error on a request
headers: 'monkey_get_test': '1000/true'
Multi-layered/deep API requests
Forward API-Monkey headers in your applications to reach and control deeper nested Endpoints
app; app;
Wildcards
Match route paths with wildcards. (currently supports: "*" for single path tokens and "**" for all remaining path tokens)
request
Other examples:
headers: 'monkey_get_users_*_stories' : 'none/500' // matches routes like: GET users/:id/stories
headers: 'monkey_get_users_**' : 'none/500' // matches routes like: GET users/../...