You are previewing Node.js Blueprints.
O'Reilly logo
Node.js Blueprints

Book Description

Develop stunning web and desktop applications with the definitive Node.js

In Detail

Node.js has emerged as a strong alternative to PHP, and has taken the world of web development by storm. Node.js is a platform that's used to build fast, scalable network applications using JavaScript as a server-side scripting language.

Starting with an overview of the most popular programming paradigms, you will venture out on a journey to the depths of Node.js, utilizing its capabilities to conceptualize and develop applications using AngularJS, Socket.IO, Backbone.js, Ember.js, and Grunt.

Packed with real-world examples and trade secrets gained from years of experience in the web development domain, this book takes you to the next level and teaches you everything you need to know to utilize the astronomical potential of Node.js. As a JavaScript platform, Node.js can also be used for desktop application development, which you will learn about in the final chapter of this book.

What You Will Learn

  • Explore design patterns in Node.js
  • Build solid architectures by following test-driven development
  • Look beyond web applications and create your own desktop app with Node.js
  • Develop single page applications using Node.js with AngularJS, Ember.js, and Backbone.js
  • Master the Express framework and build a complete site with a real database
  • Create a real-time and fully functional online chat application with Socket.IO
  • Utilize the enormous range of Grunt and Gulp plugins
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Node.js Blueprints
      1. Table of Contents
      2. Node.js Blueprints
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
        7. Downloading the color images of this book
          1. Errata
          2. Piracy
          3. Questions
      8. 1. Common Programming Paradigms
        1. Node.js fundamentals
        2. Organizing your code logic in modules
          1. Building a car construction application
          2. Using the car's engine
        3. Understanding inter-module communication
        4. Asynchronous programming
        5. Exploring middleware architecture
        6. Composition versus inheritance
        7. Managing dependencies
        8. Summary
      9. 2. Developing a Basic Site with Node.js and Express
        1. Getting acquainted with Express
        2. Installing Express
          1. Using package.json
          2. Using a command-line tool
        3. Managing routes
        4. Handling dynamic URLs and the HTML forms
        5. Returning a response
        6. The example-logging system
        7. Summary
      10. 3. Writing a Blog Application with Node.js and AngularJS
        1. Exploring AngularJS
          1. Bootstrapping AngularJS applications
          2. Using directives and controllers
          3. Data binding
          4. Encapsulating logic with modules
          5. Preparing data with filters
          6. Dependency injection
          7. The model in the context of AngularJS
          8. Final words on AngularJS
        2. Selecting and initializing the database
          1. Using NoSQL with MongoDB
          2. Using MySQL
        3. Developing the client side with Angular
        4. Implementing a control panel
        5. Summary
      11. 4. Developing a Chat with Socket.IO
        1. Exploring WebSockets and Socket.IO
        2. Understanding the basic application structure
        3. Running the server
        4. Adding Socket.IO
        5. Writing the client side of the chat
          1. Preparing the HTML markup
          2. Writing the chat logic
        6. Implementing user-to-user communication
          1. Changing the server-side code
          2. Making changes to the frontend of the chat
        7. Summary
      12. 5. Creating a To-do Application with Backbone.js
        1. Exploring the Backbone.js framework
          1. Recognizing the framework dependency
          2. Extending the functionality
          3. Understanding Backbone.js as an event-driven framework
          4. Using models
          5. Using collections
          6. Implementing views
          7. Using the router
          8. Talking to the backend
        2. Writing the backend of the application
          1. Running the Node.js server
          2. Managing the to-do lists
        3. Writing the frontend
          1. Looking into the base of the application
          2. Listing the to-do activities
          3. Adding, deleting, and editing the to-do lists
        4. Summary
      13. 6. Using Node.js as a Command-line Tool
        1. Exploring the required modules
        2. Planning the application
        3. Obtaining images from a folder
        4. Authorizing the Flickr protocol
          1. Obtaining your application's Key and Secret
          2. Writing into the Flickr.js module
          3. Running our application tool
        5. Uploading the images
        6. Summary
      14. 7. Showing a Social Feed with Ember.js
        1. Preparing the application
        2. Running the server and delivering the assets
        3. Getting tweets based on a user handle
        4. Discovering Ember.js
          1. Knowing the dependencies of Ember.js
        5. Understanding Ember.js
          1. Exploring classes and objects in Ember.js
          2. Computed properties
          3. Router
          4. Views and templates
          5. Models
          6. Controllers
        6. Writing Ember.js
          1. Defining the templates
        7. Defining the routes
        8. Handling the user input and moving to the second screen
        9. Displaying the tweets
        10. Summary
      15. 8. Developing Web App Workflow with Grunt and Gulp
        1. Introducing the task runners
        2. Exploring Grunt
          1. Concatenating files
          2. Minifying your code
          3. Watching files for changes
          4. Ignoring files
          5. Creating our own task
          6. Generating a cache manifest file
          7. Documenting our code
        3. Discovering Gulp
          1. Installing Gulp and fetching plugins
          2. Concatenating and minifying with Gulp
          3. Creating your own Gulp plugin
        4. Summary
      16. 9. Automate Your Testing with Node.js
        1. Understanding the importance of writing tests
        2. Choosing a testing methodology
          1. Test-driven development
          2. Behavior-driven development
        3. Classifying tests
        4. Using Jasmine
          1. Installing Jasmine
          2. Defining the module for testing
          3. Following the test-driven development concept
          4. Testing the file-reading process
          5. Finding strings in the file content
          6. Writing an integration test
        5. Testing with Mocha
          1. Installation
          2. Translating our example using Mocha
          3. Selecting a reporter
        6. Testing with a headless browser
          1. Writing the subject of our test
          2. Testing with PhantomJS
            1. Developing the micro testing framework
            2. Understanding how PhantomJS works
            3. Writing the actual test
        7. Testing with DalekJS
        8. Summary
      17. 10. Writing Flexible and Modular CSS
        1. Writing modular CSS
          1. BEM (block, element, modifier)
          2. Using the Object Oriented CSS approach
            1. Separate structure and skin
            2. Separate container and content
          3. Scalable and modular architecture for CSS
          4. Atomic design
        2. Exploring CSS preprocessors
          1. Using Less
            1. Defining variables
            2. Using mixins
            3. Structuring the styles into nested definitions
          2. Using Sass
          3. Using Stylus
          4. Working with AbsurdJS
        3. Styling a simple login form
        4. Summary
      18. 11. Writing a REST API
        1. Discovering REST and API
        2. Developing an online library – a REST API
          1. Defining the API parts
          2. Writing the base
          3. Implementing the API router
          4. Writing the responder
        3. Working with the database
          1. Creating a new record
          2. Editing a record
          3. Deleting a record
          4. Displaying all the books
          5. Adding a default route
        4. Testing the API
        5. Summary
      19. 12. Developing Desktop Apps with Node.js
        1. Using node-webkit
        2. Writing the base of the application
          1. Writing the package.json file
          2. Preparing the HTML layout
          3. Designing the JavaScript base
        3. Displaying and using the working directory
          1. Displaying the current working directory
          2. Showing the files and folders
          3. Changing the current directory
          4. Copying, moving, and deleting files
        4. Extending the application
          1. Tweaking the updateFileArea function
          2. Loading a new page for the selected image
          3. Showing the image and its dimensions
          4. Removing the toolbar
        5. Summary
      20. Index