How to build mobile API with Node.js

913 views

Published on

Node-pocalypse is coming! Soon everything will be written in JavaScript.

  • Be the first to comment

  • Be the first to like this

How to build mobile API with Node.js

  1. 1. HOW TO BE PREPARED FOR NODE-POCALYPSE @tomekcejner
  2. 2. THE PRESENTER TOMEK CEJNER @tomekcejner
  3. 3. APOCALYPSE?
  4. 4. JavaScript
  5. 5. Any application that can be written in JavaScript, will eventually be written in JavaScript. http://blog.codinghorror.com/the-principle-of-least-power/ Jeff Atwood, 2007
  6. 6. CREATED IN 10 DAYS DIFFICULT CHILDHOOD FUNCTIONAL DYNAMIC
  7. 7. IN 90’S EVERYBODY NEED A WEBSITE
  8. 8. http://www.amazon.com/
  9. 9. http://www.lego.com/
  10. 10. NOW ITS 2010’S EVERYBODY NEEDS MOBILE APP
  11. 11. THAT’S ALL THANK YOU!
  12. 12. BUT, IF…
  13. 13. API
  14. 14. NO API NO PUBLIC API NO MOBILE PUBLIC API ARE YOU PREPARED?
  15. 15. WHAT MAKES API MOBILE?
  16. 16. LOW BANDWIDTH HIGH LATENCY NETWORK CONDITIONS VARY Mobile device is
  17. 17. SEND ONLY WHAT IS NEEDED
  18. 18. SCREEN-ORIENTED NO CRUD-OVER-AIR
  19. 19. AVOID MULTIPLE ROUNDTRIPS CAUSED BY LAZY DESIGN EVERY REQUEST COUNTS
  20. 20. VERSIONING OR KEEP STABLE CONTRACT
  21. 21. SECURITY AUTHENTICATION TRANSIT API ABUSE
  22. 22. ANALYTICS
  23. 23. Our approach
  24. 24. PLATFORM APIs MOBILE API
  25. 25. INTRODUCING Mobster
  26. 26. OAUTH 2.0 AUTHORIZATION API KEYS Access control
  27. 27. DATA AGGREGATION DATA FILTERING ANTI-CORRUPTION LAYER Translation
  28. 28. PUSH NOTIFICATIONS GATEWAY Mobile features
  29. 29. ENTER
  30. 30. EVENT-DRIVEN NETWORK PROGRAMS JAVASCRIPT Node.js is
  31. 31. V8 LIBUV HTTP-PARSER JS STANDARD LIBRARY
  32. 32. WHY NODE.JS?
  33. 33. DB SERVICE REQUEST REQUEST REQUEST REQUEST TRADITIONAL WAY
  34. 34. WHAT WEB SERVERS DO MOST THE TIME? THEY WAIT
  35. 35. WHAT THREADS DO MOST THE TIME? THEY SUCK
  36. 36. EVENT LOOP I/O REGISTER CALLBACK OPERATION COMPLETE YOUR CODE YOUR CODE
  37. 37. LESS THREADS LESS MEMORY OVERHEAD LESS COMPUTATION (!)
  38. 38. NODE.JS SURVIVAL KIT
  39. 39. Editors
  40. 40. UNIT TESTING
  41. 41. NodeUnit
  42. 42. NodeUnit + Expect.js
  43. 43. NodeUnit
  44. 44. NodeUnit
  45. 45. Mocha
  46. 46. Mocha
  47. 47. PACKAGE MANAGEMENT
  48. 48. pom.xml
  49. 49. CHECK NODE_MODULES TO SCM
  50. 50. WEB FRAMEWORKS
  51. 51. MIDDLEWARE
  52. 52. tomek@dev_laptop$ git push appuser@server$ git pull appuser@server$ kill process_num appuser@server$ node myapp.js DEPLOYMENT
  53. 53. MANAGEMENT WITH PM2 https://github.com/unitech/pm2
  54. 54. RUN
  55. 55. RESTART
  56. 56. PROCESS LIST
  57. 57. MONITORING
  58. 58. ZERO-DOWNTIME RELOAD HEALTH CHECK API ENDPOINT LOG BROWSING LINUX STARTUP SCRIPTS Fluff
  59. 59. Automate ANSIBLE
  60. 60. SPEAKS YOUR LANGUAGE AGENTLESS Ansible
  61. 61. CODE
  62. 62. GOOGLE: JAVASCRIPT GARDEN http://bonsaiden.github.io/JavaScript-Garden/
  63. 63. JAVASCRIPT QUIRKS JSLINT & JSHINT TO RESCUE
  64. 64. ASYNCHRONOUS PROGRAMMING, M**********R
  65. 65. ASYNC TO RESCUE https://github.com/caolan/async
  66. 66. https://github.com/caolan/async
  67. 67. TO NODE OR NOT TO NODE
  68. 68. DEVELOP FAST DEPLOY FAST IT’S JAVASCRIPT
  69. 69. IT’S JAVASCRIPT NOT SO MATURE NOT FOR CPU-INTENSIVE JOBS
  70. 70. THANK YOU

×