售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Node.js By Example
Table of Contents
Node.js By Example
Credits
About the Author
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. Node.js Fundamentals
Understanding the Node.js architecture
Installing Node.js
Running Node.js server
Defining and using modules
Managing and distributing packages
Creating a module
Using modules
Updating our module
Introducing built-in modules
Creating a server with the HTTP module
Reading and writing to files
Working with events
Managing child processes
Summary
2. Architecting the Project
Introducing the basic layers of the application
The task runner and building system
Introducing Grunt
Discovering Gulp
Test-driven development
The Model-View-Controller pattern
Introducing the REST API concept
Summary
3. Managing Assets
Serving files with Node.js
CSS preprocessing
Packing client-side JavaScript
Concatenating with Gulp
Modularity in the browser with RequireJS
Moving from Node.js to the browser with Browserify
Delivering HTML templates
Defining the templates in script tags
Loading the template externally
Writing HTML inside the JavaScript
Precompiling templates
Summary
4. Developing the Model-View-Controller Layers
Evolving the current setup
Directory structure
Forming the main server handlers
Implementing the router
Introducing Ractive.js
Constructing the entry point of the application
Defining a controller
Managing our views
Creating a model
Summary
5. Managing Users
Working with the MongoDB database
Installing MongoDB
Running MongoDB
Connecting to the database server
Extending the code from the previous chapter
Updating our base model class
Updating page navigation and routing
Registering a new user
Updating the frontend
Updating the backend API
User authentication with sessions
Managing a user's profile
Summary
6. Adding Friendship Capabilities
Finding friends
Adding the search page
Writing the model
Fetching friends from the database
Marking users as friends
Displaying the linked users on the Profile page
Summary
7. Posting Content
Posting and storing text
Adding a form to post text messages
Introducing the content's model
Updating the controller of the home page
Storing content in the database
Showing the user's feed
Posting files
Summary
8. Creating Pages and Events
Refactoring the API
Adding a form to create pages
Creating a record in the database
Showing the currently added pages
Showing a specific page
Posting a comment to a page
Showing the comments
Managing events attached to a particular page
Summary
9. Tagging, Sharing, and Liking
Selecting friends and sending their IDs to the backend
Storing the tagged users and displaying them in the user's feed
Sharing a post
Liking posts and counting the number of likes
Showing the number of likes
Summary
10. Adding Real-time Chat
Getting to know WebSockets
Bringing Socket.IO to the project
Preparing the UI of the chat area
Exchanging messages between the client and the server
Sending messages to the user's friends only
Customizing the output of the chat
Summary
11. Testing the User Interface
Introducing the basic testing toolset
The testing framework
The assertion library
Runner
Preparing our project to run tests
Running our test with PhantomJS
Testing user registration
Simulating user interaction
Filling and submitting the registration form
Tweaking the code's execution order
Listening to the form-submitted event
Testing with DalekJS
Installing DalekJS
Using the DalekJS API
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜