SlideShare a Scribd company logo
build a


HTTP WEB API
          w/ nodejs & mongodb
tweet tweet @donnfelker
github.com/donnfelker/workout-tracker
agenda


         nodejs
         express
         mongoose
         mongodb
beginner | intermediate
what is   ?
Node.js is a platform built on Chrome's JavaScript runtime
for easily building fast, scalable network applications.

Node.js uses an event-driven, non-blocking I/O model that
makes it lightweight and efficient, perfect for data-intensive
real-time applications that run across distributed devices.

                                            -nodejs.org
standing on the shoulders of giants
Building HTTP API's with NodeJS and MongoDB
how do I build a web api with nodejs?
basic tools   blank slate
expressjs.com




express
web application
framework for
node
express()
Create an express application.
var express = require('express');
var app = express();

app.get('/', function(req, res){
  res.send('hello world');
});

app.listen(3000);
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);
persistence
what is mongoDB ?
MongoDB (from "humongous") is a scalable, high-
performance, open source NoSQL database.


                               - mongodb.org
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"
      }
express
 nodejs

mongoose
mongodb
mongoosejs.com




mongoose
var 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');
});
building the web api
new express project

create a folder for the app    mkdir workout-tracker



create 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
$ npm ls
workout-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
ok stop - code time
learn js
the right way
code      github.com/donnfelker/workout-tracker

twitter   @donnfelker

          MongoHub

More Related Content

What's hot (20)

PPTX
Introduction to node.js GDD
Sudar Muthu
 
PDF
Getting started with developing Nodejs
Phil Hawksworth
 
PDF
Introduction to Node.js
Rob O'Doherty
 
PPTX
Node js introduction
Joseph de Castelnau
 
PPTX
Introduction to Node js
Akshay Mathur
 
PPTX
Future of NodeJS
Sébastien Pertus
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Introduction to Node.js
Vikash Singh
 
PPT
RESTful API In Node Js using Express
Jeetendra singh
 
PDF
Node.js and How JavaScript is Changing Server Programming
Tom Croucher
 
PPTX
Introduction to node.js by jiban
Jibanananda Sana
 
PDF
Create a RESTful API with NodeJS, Express and MongoDB
Hengki Sihombing
 
KEY
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
PPTX
Node js Introduction
sanskriti agarwal
 
PDF
Use Node.js to create a REST API
Fabien Vauchelles
 
PDF
Nodejs in Production
William Bruno Moraes
 
PPTX
Introduction Node.js
Erik van Appeldoorn
 
PPTX
Nodejs intro
Ndjido Ardo BAR
 
PPTX
Introduction to node.js
Dinesh U
 
PDF
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Introduction to node.js GDD
Sudar Muthu
 
Getting started with developing Nodejs
Phil Hawksworth
 
Introduction to Node.js
Rob O'Doherty
 
Node js introduction
Joseph de Castelnau
 
Introduction to Node js
Akshay Mathur
 
Future of NodeJS
Sébastien Pertus
 
NodeJS for Beginner
Apaichon Punopas
 
Introduction to Node.js
Vikash Singh
 
RESTful API In Node Js using Express
Jeetendra singh
 
Node.js and How JavaScript is Changing Server Programming
Tom Croucher
 
Introduction to node.js by jiban
Jibanananda Sana
 
Create a RESTful API with NodeJS, Express and MongoDB
Hengki Sihombing
 
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
Node js Introduction
sanskriti agarwal
 
Use Node.js to create a REST API
Fabien Vauchelles
 
Nodejs in Production
William Bruno Moraes
 
Introduction Node.js
Erik van Appeldoorn
 
Nodejs intro
Ndjido Ardo BAR
 
Introduction to node.js
Dinesh U
 
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 

Similar to Building HTTP API's with NodeJS and MongoDB (20)

PPTX
Zero to Hipster with the M.I.K.E. Stack
Jen Looper
 
PDF
Node.js - async for the rest of us.
Mike Brevoort
 
PPTX
Herramientas front
borya09
 
PPTX
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
MongoDB
 
PDF
Beginning MEAN Stack
Rob Davarnia
 
PPTX
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
PPTX
Back to Basics Webinar 2 - Your First MongoDB Application
Joe Drumgoole
 
PDF
Back to Basics 2017: Mí primera aplicación MongoDB
MongoDB
 
PDF
NodeJS @ ACS
Mauro Parra-Miranda
 
PPTX
Mongoose and MongoDB 101
Will Button
 
KEY
Practical Use of MongoDB for Node.js
async_io
 
PDF
Introduction to REST API with Node.js
Yoann Gotthilf
 
PDF
Intro to node.js - Ran Mizrahi (27/8/2014)
Ran Mizrahi
 
PDF
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
PPTX
MongoDB Days UK: Building Apps with the MEAN Stack
MongoDB
 
PDF
Basic API Creation with Node.JS
Azilen Technologies Pvt. Ltd.
 
PDF
Parse cloud code
維佋 唐
 
PPTX
Node js crash course session 5
Abdul Rahman Masri Attal
 
PDF
Node.js :: Introduction — Part 2
Roman Liutikov
 
PDF
Node.js with MySQL.pdf
SudhanshiBakre1
 
Zero to Hipster with the M.I.K.E. Stack
Jen Looper
 
Node.js - async for the rest of us.
Mike Brevoort
 
Herramientas front
borya09
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
MongoDB
 
Beginning MEAN Stack
Rob Davarnia
 
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
Back to Basics Webinar 2 - Your First MongoDB Application
Joe Drumgoole
 
Back to Basics 2017: Mí primera aplicación MongoDB
MongoDB
 
NodeJS @ ACS
Mauro Parra-Miranda
 
Mongoose and MongoDB 101
Will Button
 
Practical Use of MongoDB for Node.js
async_io
 
Introduction to REST API with Node.js
Yoann Gotthilf
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
MongoDB Days UK: Building Apps with the MEAN Stack
MongoDB
 
Basic API Creation with Node.JS
Azilen Technologies Pvt. Ltd.
 
Parse cloud code
維佋 唐
 
Node js crash course session 5
Abdul Rahman Masri Attal
 
Node.js :: Introduction — Part 2
Roman Liutikov
 
Node.js with MySQL.pdf
SudhanshiBakre1
 
Ad

More from donnfelker (9)

PDF
Understanding Android Build Variants
donnfelker
 
PDF
Building More with Less
donnfelker
 
KEY
Android Bootstrap
donnfelker
 
KEY
Whats New in Android
donnfelker
 
KEY
Android Bootstrap
donnfelker
 
KEY
Outsourcing Do's and Don'ts
donnfelker
 
PDF
Advanced android
donnfelker
 
PPTX
Introduction to Android Development
donnfelker
 
PPT
20080531 Intro To Dependency Injection & Inversion Of Control
donnfelker
 
Understanding Android Build Variants
donnfelker
 
Building More with Less
donnfelker
 
Android Bootstrap
donnfelker
 
Whats New in Android
donnfelker
 
Android Bootstrap
donnfelker
 
Outsourcing Do's and Don'ts
donnfelker
 
Advanced android
donnfelker
 
Introduction to Android Development
donnfelker
 
20080531 Intro To Dependency Injection & Inversion Of Control
donnfelker
 
Ad

Recently uploaded (20)

PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
July Patch Tuesday
Ivanti
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
July Patch Tuesday
Ivanti
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 

Building HTTP API's with NodeJS and MongoDB

Editor's Notes