Node.js By Example
eBook - ePub

Node.js By Example

Krasimir Tsonev

Share book
  1. 220 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Node.js By Example

Krasimir Tsonev

Book details
Book preview
Table of contents
Citations

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Node.js By Example an online PDF/ePUB?
Yes, you can access Node.js By Example by Krasimir Tsonev in PDF and/or ePUB format, as well as other popular books in Computer Science & Open Source Programming. We have over one million books available in our catalogue for you to explore.

Information

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

Node.js By Example

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: May 2015
Production reference: 1190515
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-571-1
www.packtpub.com

Credits

Author
Krasimir Tsonev
Reviewers
Danny Allen
Alex (Shurf) Frenkel
Commissioning Editor
Akram Hussain
Acquisition Editors
Purav Motiwalla
Llewellyn Rozario
Content Development Editor
Shubhangi Dhamgaye
Technical Editor
Mrunal M. Chavan
Copy Editor
Vedangi Narvekar
Project Coordinator
Harshal Ved
Proofreaders
Stephen Copestake
Safis Editing
Indexer
Priya Sane
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade

About the Author

Krasimir Tsonev is a coder with over 10 years of experience in web development. The author of Node.js Blueprints, Packt Publishing, he works with a strong focus on quality and usability. Krasimir is interested in delivering cutting-edge applications. He enjoys working in the software industry and has a passion for creating and discovering new and effective digital experiences. Right now, he is working with technologies such as HTML5/CSS3, JavaScript, PHP, and Node.js, but he originally started out as a graphic designer. Later, being a Flash developer, he spent several years using ActionScript3 and frameworks such as RobotLegs. After that, as a freelancer, he continued to deliver full-stack web services for his clients, taking care of the graphic design and frontend and backend programming. Right now, with the rise of mobile application development, Krasimir is enthusiastic about working on responsive applications that target various devices. He currently lives and works in Bulgaria. He graduated from the Technical University of Varna with both a bachelor's and a master's degree in computer science. He loves blogging, writing books, and giving talks on the latest trends in web development.
He has authored Node.js Blueprints, Packt Publishing (https://www.packtpub.com/web-development/nodejs-blueprints).

About the Reviewers

Danny Allen is a full-stack web developer who focuses on usability, user experience, localization, and accessibility issues as the founder and director of the international user experience development consultancy Wonderscore Ltd.
Skilled in a wide range of backend and frontend technologies including Python, Django, JavaScript, Node.js, as well as HTML5/CSS3, his recent work has involved the design and implementation of e-learning and government projects in the United Kingdom.
His portfolio and contact details can be found at http://dannya.uk.
Alex (Shurf) Frenkel has worked in the field of web application development since 1998 (the beginning of PHP 3.X) and has extensive experience in system analysis and project managemen...

Table of contents