Home Page Icon
Home Page
Table of Contents for
Cover
Close
Cover
by Jason Krol
Web Development with MongoDB and Node.js
Web Development with MongoDB and Node.js
Table of Contents
Credits
About the Author
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
What you need for this book
Who this book is for
Conventions
Reader feedback
1. Welcome to JavaScript in the Full Stack
Node.js changed JavaScript forever
Asynchronous callbacks
Node Package Manager
Networking and file IO
Not just on the web
Real-time web with Socket.io
The NoSQL movement
Node and MongoDB in the wild
What to expect from this book
Summary
2. Getting Up and Running
Environment assumptions and requirements
Installing Node.js
Mac OS X installation instructions
Windows 7 or 8 installation instructions
Linux installation instructions
Confirming successful Node.js installation
Bookmarking the online documentation
Installing the MongoDB server
Mac OS X installation instructions
Windows 7 or 8 installation instructions
Linux installation instructions
Confirming successful MongoDB installation
Bookmarking the online documentation
Writing your first app
The code
Launch the sample app
Check the actual database
Summary
3. Node and MongoDB Basics
A JavaScript Primer
Declaring variables
Declaring functions
Declaring objects
Functions are objects
Anonymous functions and callbacks
Arrays
Conditions and comparison operators
Flow
JSON
The basics of NodeJS
Event driven
Asynchronous
Require and modules
The NodeJS core
Installing modules using npm
The basics of MongoDB
The mongo shell
Inserting data
Querying
Updating data
Deleting data
Summary
4. Writing an Express.js Server
What is Express.js?
Building a complete web application
Organizing the files
Server.js – where it all begins
Booting up server.js
Configuration module
Handlebars view engine
Other template engines
Using and understanding middleware
Introducing Connect
Activating the configure module
Routers and controllers
Migrating to Express v4.0.0
Using new middleware
server/configure.js
server/routes.js
Summary
5. Dynamic HTML with Handlebars
Basic syntax for Handlebars
Views
Layouts
Partial views
Handlebars Helpers
Global helpers
View-specific helpers
Rendering the views
Summary
6. Controllers and View Models
Controllers
View models
Updating the home controller
Updating the image controller
Displaying an image
Uploading an image
Helpers for reusable code
The sidebar module
The stats module
The images module
The comments module
Testing the sidebar implementation
Summary
7. Persisting Data with MongoDB
Using MongoDB with Node
Connecting to MongoDB
Inserting a document
Retrieving a document
Introducing Mongoose
Schemas
Models
Built-in validation
Static methods
Virtual properties
Connecting with Mongoose
Defining the schema and models
Models index file
Adding CRUD to the controllers
The home controller
The image controller
Index – retrieving an image model
Create – inserting an image model
Testing everything out so far
Like – updating an image model
Comment – inserting a comment model
Wrapping it up
Helpers
Introducing the async module
The comments helper
The helper sidebar
Troubleshooting
The stats helper
The popular images helper
Iterating by adding an image removal capability
Adding a route
Adding a controller handler
Updating the Handlebars image page template
Updating the jQuery
Refactoring and improvements
Summary
8. Creating a RESTful API
What is an API?
What is a RESTful API?
Introducing Postman REST Client
Installation instructions
A quick tour of Postman REST Client
Using the JSONView Chrome extension
Creating a Basic API server
Creating sample JSON data
Responding to GET requests
Receiving data – POST and PUT requests
Removing data – DELETE
Consuming external APIs from Node.js
Consuming an API endpoint using Request
Summary
9. Testing Your Code
Tools of the trade
Running tests with the Mocha framework
Asserting tests with Chai.js
Installing Chai.js as a devDependency
Spies and stubs with Sinon.js
Stubbing node modules with Proxyquire
Testing the application
Testing the routes
Testing the server
Testing a model
Testing a controller
Summary
10. Deploying with Cloud-based Services
Cloud versus traditional hosting
Infrastructure as a Service (IaaS) versus Platform as a Service (PaaS)
Introduction to Git
Deploying your application
Nodejitsu
Heroku
Amazon Web Services (AWS)
Create a MongoLab account and database
Create and configure the AWS environment
Microsoft Azure
Digital Ocean
Summary
11. Single Page Applications with Popular Frontend Frameworks
What is a Single Page Application?
Frontend development tools
Automated build task managers
Dependency management
Modularity
HTML template-rendering engines
CSS transpiling
Testing and test-driven development
PhantomJS headless browser
Summary
12. Popular Node.js Web Frameworks
Meteor
Sails
hapi
Koa
Flatiron
Summary
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Table of Contents
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset