Your SlideShare is downloading. ×
Node.js hackathon
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Node.js hackathon

977
views

Published on

Bob Corsaro (@doki_pen) presentation from Traackr Haackr Day

Bob Corsaro (@doki_pen) presentation from Traackr Haackr Day

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
977
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. API Best Practices
  • 2. Who are you?● bit.ly/rcorsaro● @doki_pen● github.com/dokipen● works @ embed.ly
  • 3. Agenda● Nodejs intro● API Recipe● Demo● Questions
  • 4. Node Intro
  • 5. Why Node?● Async, fast enough for web programming● Very active and talented community● NPM makes code reuse a breeze● Honestly, javascript isnt that bad
  • 6. Installing Nodehttps://github.com/creationix/nvm $ git clone git://github.com/creationx/nvm.git ~/nvm $ . ~/nvm/nvm.sh $ nvm install v0.8.6 $ nvm alias default 0.8.6
  • 7. Hello Worldvar http = require(http);http.createServer(function (request, response) { response.writeHead(200, {Content-Type: text/plain}); response.end(Hello Worldn);}).listen(8124);console.log(Server running at http://127.0.0.1:8124/);
  • 8. Debugginghttps://github.com/dannycoates/node-inspector
  • 9. Testing● https://github.com/visionmedia/should.js● https://github.com/visionmedia/mocha● https://github.com/visionmedia/supertest
  • 10. NPM Everything { "name": "hackathon", "version": "0.0.1", "description": "My hackathon project", "main": "index.js", "scripts": { "test": "mocha" }, "dependencies": { "express": "3.0.0rc2", "mongodb": "0.0.1" }, "devDependencies": { "mocha": "*", "should": "*", "supertest": "*" }, "author": "Bob Corsaro", "license": "MIT" }
  • 11. API Recipe
  • 12. API Recipe (Yak Shaving)● Documentation● Performance tracking● Authentication● Usage tracking● Access Control (rate-limits, privileges)● The actual service (and tests)There are companies that do a lot of this foryou for $. (mashery, apigee, 3scale)
  • 13. DocumentationRemember wsdls? Contracts matter. Discoverymatters.https://github.com/wordnik/swagger-node-expresshttps://github.com/dokipen/express-endpoint
  • 14. Performance Tracking● http://graphite.wikidot.com/● https://github.com/etsy/statsd● https://github.com/dokipen/connect-statsdBSD, Solaris or SmartOS dtraceLinux =(
  • 15. AuthenticationIf your API is public, youll want to do thefollowing.● Distribute keys (we have a django app for that) uuid4 is good● Authenticate keys (we have a connect middleware for that)● Support 2-legged OAuth. Version 1.0a is fine.● Ability to block keys (well use it later)
  • 16. Usage TrackingAnalytics vs. Rate LimitingSync vs. Async
  • 17. Access Control● Support JSONP● Support CORShttp://enable-cors.org/ Access-Control-Allow-Methods: GET, OPTIONS Access-Control-Allow-Origin: *
  • 18. Demo
  • 19. Questions