0.3.2 • Published 6 years ago

reaper v0.3.2

Weekly downloads
75
License
MIT
Repository
github
Last release
6 years ago

Reaper

Build
Status Coverage
Status NPM
version

Reaper picks the correct media-type for a resource based on a request's Accept header and what the resource or server supports.

It also allows the registration of serializers / deserializers for automatic serialization and deserialization of any formats that might be automatically serializable/deserializable.

var reaper = new Reaper();
reaper.register('application/json', 
                function(str){ return JSON.parse(str); },
                function(obj){ return JSON.stringify(obj); });

reaper.isAcceptable('application/json');   // returns true
reaper.isAcceptable('*/*');   // returns true
reaper.isAcceptable('application/xml');   // returns false

reaper.isRegistered('application/json');  // returns true
reaper.isRegistered('application/xml');  // returns false

reaper.input("application/json", '{"hello" : "world"}');  // returns {hello : "world"}
reaper.output("application/json", {hello : "world"});   // returns '{"hello" : "world"}'

Additionally Reaper comes with a connect-compatible middleware that attaches a body and rawBody object to your request object that automatically uses any deserializer you may have configured for the content-type to populate the body property. The middleware will return errors in the case of bad deserialization, or unacceptable Accept / Content-Type headers.

0.3.2

6 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.3

12 years ago

0.2.2

12 years ago

0.2.1

12 years ago

0.2.0

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago