Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Criando API's com HapiJS

316 views

Published on

Criando API's e Microservices REST utilizando o Framework Open Source do Walmart HapiJS

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Criando API's com HapiJS

  1. 1. CRIANDO API`S EMPRESARIAIS COM @fidelissauro
  2. 2. Matheus Fidelis Developer / DevOps Superlógica Tecnologias Twitter: @fidelissauro Github: /msfidelis Blog: nanoshots.com.be 2
  3. 3. “Any application that can be written in Javascript, will eventually be written in Javascript” Jeff Atwood - co-fundador da StackOverflow 3
  4. 4. ● Criado por Eran Hammer ● Sr. Architect of Mobile Platform ● Responsável pela arquitetura das maiores aplicações Mobile no Walmart ● OAuth e OAuth2 4
  5. 5. ● Express não foi suficiente para o Walmart ● Falhou em grandes equipes e grandes projetos. ● Queria uma solução corporativa. 5
  6. 6. OPEN SOURCE https://github.com/walmartlabs
  7. 7. ● Criado para grandes equipes ● Sistemas complexos ● Ideal para alta disponibilidade ● Segurança ● Proteção de Memória ● Proteção do Event Loop ● Gerenciamento de Timeouts ● Validações Integradas ● Tratamento de Requests abortados, lifecycle, limites de clientes e etc 7
  8. 8. 8 REN & STIMPY
  9. 9. COMPARAÇÕE S 9
  10. 10. 10 SERVER
  11. 11. 11 ROUTES
  12. 12. 12 ROUTES
  13. 13. 13 BENCHMARKS https://raygun.com/blog/node-performance/
  14. 14. 14 SO QUE ASSIM...
  15. 15. 15 NA VIDA REAL... ▫ Hapi ▫ Express ▫ Body-parser ▫ Cookie-parser ▫ Consign ▫ Muster ▫ … middlewares
  16. 16. 16
  17. 17. 17 NA VIDA REAL... ▫ Express é uma abstração do HTTP Kernel do Node. ▫ Express te provê ROTAS. Apenas. ▫ Hapi faz vários tratamentos, debug, fallbacks ▫ Proteção do Lifecycle do request ▫ Proteção da memória ▫ Todo o acompanhamento e parsing do HTTP
  18. 18. 18 NO GERAL... ▫ Para aplicações grandes ▫ Apps com muitos devs ▫ Apps com muitas validações e segurança ▫ Coisas Simples ▫ Interfaces REST ▫ POC’s e Services ▫ Cloud Functions
  19. 19. 19 DOCKER
  20. 20. PLUGINS https://hapijs.com/plugin s 20
  21. 21. ▫ Isso sobre m#rd@ ▫ Exceptions Logging ▫ Legal pra registrar Dumps ▫ Logs limpos para rastreio 21 https://github.com/hapijs/poop
  22. 22. ▫ Validação ▫ Validação agressiva dos requests ▫ Resource Responsibility 22 https://github.com/hapijs/joi
  23. 23. 23 https://github.com/hapijs/joi
  24. 24. ▫ HTTP-friendly ▫ Error Response Codes 24 https://github.com/hapijs/boom
  25. 25. 25 https://github.com/hapijs/boom
  26. 26. 26 https://github.com/hapijs/boom ▫ 4xx ▫ Boom.badRequest() - 400 ▫ Boom.unauthorized() - 401 ▫ Boom.forbidden() - 403 ▫ Boom.notFound - 404 ▫ 5xx ▫ Boom.notFound() - 500 ▫ Boom.notImplemented - 501 ▫ Boom.serverUnavailable() - 503
  27. 27. ▫ Console web para debug ▫ Vários servidores Hapi ▫ Logs dos Requests ▫ Logs limpos para rastreio 27 https://github.com/hapijs/tv
  28. 28. 28
  29. 29. ▫ Gerenciador de Templates ▫ EJS ▫ Jade ▫ Mustache ▫ Nunjucks 29 https://github.com/hapijs/vision VISION
  30. 30. ▫ PROXY HANDLER ▫ Proxy e Gateway ▫ Altamente customizável 30 https://github.com/hapijs/h2o2 H2O2
  31. 31. 31 https://github.com/hapijs/h2o2 H2O2
  32. 32. 32 https://github.com/ryanfitz/hapi-auth-jwt https://github.com/dwyl/hapi-auth-jwt2 JWT/JWT2
  33. 33. 33 JWT/JWT2
  34. 34. 34 Authentication ▫ HTTP Basic authentication ▫ https://github.com/hapijs/hapi-auth-basic ▫ Bearer token based authentication ▫ https://github.com/johnbrett/hapi-auth-bearer- token ▫ Firebase ▫ https://github.com/dsdenes/hapi-auth-firebase
  35. 35. 35 Messaging ▫ Hapi-rabbit - RabbitMQ ▫ https://github.com/aduis/hapi-rabbit ▫ Hapi-plugin-websocket ▫ https://github.com/rse/hapi-plugin-websocket ▫ Susie ▫ https://github.com/mtharrison/susie
  36. 36. 36 Routes ▫ acquaint ▫ https://github.com/genediazjr/acquaint ▫ hapi-routes ▫ https://github.com/bsiddiqui/hapi-router ▫ hapi-auto-route ▫ https://github.com/sitrakay/hapi-auto-route
  37. 37. 37 https://hapijs.com/communit y
  38. 38. 38 Hapi e Eu
  39. 39. 39 Boreal Server https://github.com/msfidelis/boreal
  40. 40. 40 Boreal Server https://github.com/msfidelis/boreal https://hub.docker.com/r/msfidelis/boreal ▫ “RESTfica” qualquer banco MySQL ▫ MySQL, MariaDB, Aurora Servers ▫ Caching, Query Builder com HTTP methods, Process Management. ▫ Deploy do banco de dados como um Microservice ▫ Feito para rodar com Docker!
  41. 41. 41 Pocket Gateway https://github.com/msfidelis/pocket- gateway ▫ Micro API Gateway.
  42. 42. 42 Perguntas? ▫ https://twitter.com/fidelissauro ▫ https://github.com/msfidelis ▫ http://nanoshots.com.br ▫ msfidelis01@gmail.com
  43. 43. 43 https://github.com/msfidelis/hapijs-demo
  44. 44. 44 DEMO/DOJO

×