17
Building Restful APIs with HarvesterJS Marcelo Cure

Building restful ap is with harvester js

Embed Size (px)

Citation preview

Page 1: Building restful ap is with harvester js

Building Restful APIs

with HarvesterJS

Marcelo Cure

Page 2: Building restful ap is with harvester js

Marcelo Cure

Software Developer since 2007Work at ilegraTwitter: @__cure

Page 3: Building restful ap is with harvester js

What is HarvesterJS?open-source library

Fork of FortuneJS

Build on the top of Express

Persistence (GET, POST, PUT, DELETE)

Lightweight

Page 4: Building restful ap is with harvester js

JSON API CompliantSpecification for APIs

Defines standards for success/failure paylods

Defines standards to expose linked resources

Defines standards for querying

Page 5: Building restful ap is with harvester js

Why JSON API?Standard

Different APIs communicating in a common language

Saves developers’s time

Scary at first .. but it’s worth it

Page 6: Building restful ap is with harvester js

HTTP Statuses

http://http.cat/{statusCode}

Page 7: Building restful ap is with harvester js

Contracts

Page 8: Building restful ap is with harvester js

Easy to create resourcesJoi for describing and validating resources;

Contract validation by default;

Before and After persistency actions

Page 9: Building restful ap is with harvester js

Easy to setupJust a few lines of code

Just a little configuration

Page 10: Building restful ap is with harvester js

Extensible

????

Page 11: Building restful ap is with harvester js

Easy to customize routesharvesterApp.router.get

harvesterApp.router.post

harvesterApp.router.put

harvesterApp.router.delete

Page 12: Building restful ap is with harvester js

LimitationsCannot walk through a path like: /bands/123/albuns;

Mongo Oplog connection string required;

Resource with subdocument;

Page 13: Building restful ap is with harvester js
Page 14: Building restful ap is with harvester js

Production?

Page 15: Building restful ap is with harvester js

It’s Open Source

Page 16: Building restful ap is with harvester js

Referenceshttps://github.com/agco/harvesterjs/

http://jsonapi.org/

https://github.com/hapijs/joi

https://expressjs.com/

http://http.cat/

Page 17: Building restful ap is with harvester js