Upload
marcelo-cure
View
176
Download
2
Embed Size (px)
Citation preview
Building Restful APIs
with HarvesterJS
Marcelo Cure
Marcelo Cure
Software Developer since 2007Work at ilegraTwitter: @__cure
What is HarvesterJS?open-source library
Fork of FortuneJS
Build on the top of Express
Persistence (GET, POST, PUT, DELETE)
Lightweight
JSON API CompliantSpecification for APIs
Defines standards for success/failure paylods
Defines standards to expose linked resources
Defines standards for querying
Why JSON API?Standard
Different APIs communicating in a common language
Saves developers’s time
Scary at first .. but it’s worth it
HTTP Statuses
http://http.cat/{statusCode}
Contracts
Easy to create resourcesJoi for describing and validating resources;
Contract validation by default;
Before and After persistency actions
Easy to setupJust a few lines of code
Just a little configuration
Extensible
????
Easy to customize routesharvesterApp.router.get
harvesterApp.router.post
harvesterApp.router.put
harvesterApp.router.delete
LimitationsCannot walk through a path like: /bands/123/albuns;
Mongo Oplog connection string required;
Resource with subdocument;
Production?
It’s Open Source
Referenceshttps://github.com/agco/harvesterjs/
http://jsonapi.org/
https://github.com/hapijs/joi
https://expressjs.com/
http://http.cat/