Building HTTP API's with NodeJS and MongoDB

  • 2,346 views
Uploaded on

Slide deck for the presentation on building web api's with nodejs and mongodb.

Slide deck for the presentation on building web api's with nodejs and mongodb.

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,346
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
66
Comments
0
Likes
2

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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. build aHTTP WEB API w/ nodejs & mongodb
  • 2. tweet tweet @donnfelker
  • 3. github.com/donnfelker/workout-tracker
  • 4. agenda nodejs express mongoose mongodb
  • 5. beginner | intermediate
  • 6. what is ?
  • 7. Node.js is a platform built on Chromes JavaScript runtimefor easily building fast, scalable network applications.Node.js uses an event-driven, non-blocking I/O model thatmakes it lightweight and efficient, perfect for data-intensivereal-time applications that run across distributed devices. -nodejs.org
  • 8. standing on the shoulders of giants
  • 9. how do I build a web api with nodejs?
  • 10. basic tools blank slate
  • 11. expressjs.comexpressweb applicationframework fornode
  • 12. express()Create an express application.var express = require(express);var app = express();app.get(/, function(req, res){ res.send(hello world);});app.listen(3000);
  • 13. express()Create an express application.var express = require(express);var app = express();app.get(/, function(req, res){ res.json(200, { message : “Hi!” });});app.listen(3000);
  • 14. persistence
  • 15. what is mongoDB ?
  • 16. MongoDB (from "humongous") is a scalable, high-performance, open source NoSQL database. - mongodb.org
  • 17. records are stored known as ‘documents’ and resemble json { "_id": "4ff09aabf2c99f6cac000006", "description": "21-15-9 of Thrusters and Pull Ups", "name": "Fran", "date_created": "2012-07-01T18:44:59.580Z" }
  • 18. express nodejsmongoosemongodb
  • 19. mongoosejs.commongoosevar mongoose = require(mongoose);var db = mongoose.createConnection(localhost, workout_tracker);var schema = mongoose.Schema({ name: string });var Workout = db.model(workout, schema);var w = new Workout({ name: Fran });w.save(function (err) { if (err) // ... res.end(meow);});
  • 20. building the web api
  • 21. new express projectcreate a folder for the app mkdir workout-trackercreate a package.json file { with these contents "name": "workout-tracker", "description": "workout tracker app", "version": "0.0.1", "private": true, "dependencies": { "express": "3.x" } } install dependencies and $ npm install install express
  • 22. $ npm lsworkout-tracker@0.0.1 /private/tmp!"# express@3.0.0beta7 $"" commander@0.6.1 $"# connect@2.3.9 % $"" bytes@0.1.0 % $"" cookie@0.0.4 % $"" crc@0.2.0 % $"" formidable@1.0.11 % !"" qs@0.4.2 $"" cookie@0.0.3 $"" debug@0.7.0 $"" fresh@0.1.0 $"" methods@0.0.1 $"" mkdirp@0.3.3 $"" range-parser@0.0.4 $"# response-send@0.0.1 % !"" crc@0.2.0 !"# send@0.0.3 !"" mime@1.2.6
  • 23. ok stop - code time
  • 24. learn jsthe right way
  • 25. code github.com/donnfelker/workout-trackertwitter @donnfelker MongoHub