售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Web Development with MongoDB and NodeJS Second Edition
Table of Contents
Web Development with MongoDB and NodeJS Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Welcome to JavaScript in the Full Stack
A short introduction to Node.js
The advantage that the V8 engine brings in
Node.js is single threaded!
Non-blocking asynchronous execution
npm – the Node Package Manager
Sharing and reusing JavaScript
Not just for building web servers!
Real-time web application with Socket.io
Networking and file IO
The origin of io.js
A simple server with Node.js
When to use Node.js?
The NoSQL movement
A short introduction to MongoDB
Features of MongoDB
Node and MongoDB in the wild
What to expect from this book
Summary
2. Getting Up and Running
Installing Node.js
Mac OS X
Windows
Linux
Testing whether Node.js is installed properly
Online documentation
Installing MongoDB
Mac OS X installation instructions
Windows 7 / Windows 8 installation instructions
Linux installation instructions
Confirming successful MongoDB installation
Bookmark the online documentation
Writing your first app
Creating the sample application
Getting the dependent modules in place
Adding the application code
Understanding the code
Launching the sample app
Checking the actual database
Summary
3. Node and MongoDB Basics
A JavaScript primer
Syntax basics
Data types
Understanding the scope of variables
Operators and flows
Understanding objects
Understanding arrays
Understanding functions
Anonymous functions and callbacks
JSON
The basics of Node.js
Event-driven
Asynchronous execution
The module system
The Node.js core
Installing modules using npm
The basics of MongoDB
The Mongo shell
Inserting data
Querying
Updating data
Deleting data
Additional resources
Summary
4. Introducing Express
Web application frameworks
What is Express.js?
Building a complete web application
Designing the web application
Organizing the files
Creating the application's entry point
Booting up the application
Using and understanding middleware
The configure module
Activating the configure module
Routers and controllers
Custom middleware
Handlebars as view engines
Summary
5. Templating with Handlebars
Templating engines
Server-side and client-side templating
Client-side templating
Server-side templating
Views
Layouts
Partial views
The basics of Handlebars
Binding an object to the template
Embedding presentation logic
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
Iterating on the UI
Summary
7. Persisting Data with MongoDB
Using MongoDB with Node.js
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 schemas and models
The 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
The Like button and updating an image model
Comment – inserting a comment model
Wrapping it up
Helpers
Introducing the async module
The comments helper
The sidebar helper
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 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
The tools of the trade
Running tests with the Mocha framework
Asserting tests with Chai.js
Getting started with Chai
Spies and stubs with Sinon.js
Stubbing node modules with Proxyquire
Writing and running your first test
Writing a test helper
Testing the application
Testing the routes
Testing the server
Testing a model
Testing a controller
Spy and stub everything!
Summary
10. Deploying with Cloud-Based Services
Cloud versus traditional hosting
Infrastructure as a Service versus Platform as a Service
An introduction to Git
Deploying your application
Nodejitsu
Heroku
Amazon Web Services
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?
Why use a frontend framework?
The TodoMVC project
Backbone.js
Ember.js
AngularJS
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
Koa
Meteor
Sails
Hapi
Flatiron
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜