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.

Create a RESTful API with NodeJS, Express and MongoDB


Published on

Create a RESTful API with NodeJS, Express and MongoDB (MongooseJS)

Published in: Technology

Create a RESTful API with NodeJS, Express and MongoDB

  1. 1. Tech Talk Friday, 13 February 2015
  2. 2. Create a RESTful API Express +
  3. 3. Roadmap • Express Overview • MongoDB Overview • Learn Express Route • ODM MongoDB with Mongoose • Handle CRUD for an item • Use the proper HTTP verbs to make it RESTful (GET, POST, PUT, and DELETE) • Return JSON data
  4. 4. Getting Started $ curl | bash $ source ~/.nvm/ $ nvm install v0.10.36 $ nvm alias default 0.10.36 Install and Setup Install Node.JS using NVM [Node Version Manager] Install MongoDB on OS X Install MongoDB with Homebrew : $ brew install mongodb
  5. 5. MongoDB MongoDB is a document database that provides high performance, high availability, and easy scalability. source : Schema Less Data strore in JSON-like documents with dynamic Providing flexibity during the development process Built-in Javascript :)
  6. 6. “Representational State Transfer (REST) is a software architecture style consisting of guidelines and best practices for creating scalable web services. REST is a coordinated set of constraints applied to the design of components in a distributed hypermedia system that can lead to a more performant and maintainable architecture.” What is REST
  7. 7. Express Apps $ npm install $ node server.js
  8. 8. Express Route curl -i -X POST -H 'Content-Type: application/json' -d '{}' http://localhost:3000/user curl -i -X PUT -H 'Content-Type: application/json' -d '{}' http://localhost:3000/user curl -i -X DELETE -H 'Content-Type: application/json' -d '{}' http://localhost:3000/user curl -i -X GET http://localhost:3000/user
  9. 9. MongoDB with MongooseJS $ npm install —save mongoose
  10. 10. Create MongoDB Model
  11. 11. $ git clone Source Code