Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Thanks to the lock file provided by Yarn. That’s it. Not sure about tagging this as feature release.
Keep in mind that you of course still can install with npm 💖
You now can define different status codes on request level in addition to defining errors on endpoint level.
So different subroutes of one endpoint can return different HTTP status codes. Plus you can choose between:
const SetupEndpoint = require('./setup/setup.js');
module.exports = SetupEndpoint({
name: 'statusCodes',
urls: [
{
params: '/boomError',
requests: [{
// Returns a 402 status code + error message provided by boom:
// {
// "error" : "Payment Required",
// "statusCode" : 402
// }
statusCode: 402
}]
},
{
params: '/customError',
requests: [{
// Returns a HTTP status code 406 and a self defined response:
response: { error: true },
statusCode: 406
}]
},
{
params: '/regularResponse',
requests: [{
// Returns a 401 error provided by boom
// as defined on endpoint level
response: '/json-templates/anotherExample.json'
}]
}
],
statusCode: 401
});
Breaking change because the configuration object changed again. See README.