UNPKG

cannery-adapter-rest

Version:
44 lines (39 loc) 1.07 kB
'use strict'; var requests = { DELETE: { 'cars/1': function cars1(options) { return { messsage: 'Deleted Car' }; }, 'api/cars/2': function apiCars2(options) { return 'We Deleted the Car'; }, 'foo/bar/baz': function fooBarBaz() { return { message: 'Yay' }; } } }; module.exports = function (method, url, options) { return new Promise(function (resolve, reject) { if (url !== 'cars/404') { return resolve({ statusCode: 200, headers: options.headers, getBody: function getBody() { var body = requests[method][url](options); return JSON.stringify(body); } }); } return reject({ statusCode: 404, headers: options.headers, getBody: function getBody() { return 'File not found'; } }); }); };