Meteor in Action
Stephan Hochhaus and Manuel Christoph Schoebel
Foreword by Matt DeBergalis
  • September 2015
  • ISBN 9781617292477
  • 368 pages
  • printed in black & white

An enjoyable and approachable book.

From the Foreword by Matt DeBergalis, Founder Meteor Development Group

Meteor in Action teaches you full-stack web development using the Meteor platform. It starts with an overview of a Meteor application, revealing the unique nature of Meteor's end-to-end application model. Then you'll dive into the Blaze templating engine, discover Meteor's reactive data sources model, learn simple and advanced routing techniques, and practice managing users, permissions, and roles.

Table of Contents detailed table of contents

foreword

preface

acknowledgments

about this book

Author Online

About the authors

about the cover illustration

Part 1: Look—a shooting star!

1. A better way to build apps

1.1. Introducing Meteor

1.1.1. The story behind Meteor

1.1.2. The Meteor stack

1.1.3. Isomorphic frameworks: full-stack JavaScript

1.1.4. Processing in the browser: running on distributed platforms

1.1.5. Reactive programming

1.2. How Meteor works

1.2.1. Core projects

1.2.2. Isobuild and the CLI tool

1.2.3. Client code vs. server code

1.3. Strengths and weaknesses

1.3.1. Where Meteor shines

1.3.2. Challenges when using Meteor

1.4. Creating new applications

1.4.1. Setting up a new project

1.4.2. Starting the application

1.5. Dissecting the default project

1.5.1. helloWorld.css

1.5.2. helloWorld.html

1.5.3. helloWorld.js

1.6. Summary

2. My fridge! A reactive game

2.1. Application overview

2.2. Initial setup

2.2.1. Setting up a new project

2.3. Creating a layout

2.3.1. Setting the styles

2.3.2. Adding the templates

2.4. Adding content to the database in real time

2.4.1. Storing items in the database

2.4.2. Connecting data to templates

2.4.3. Adding a defined set of products

2.5. Moving items into the fridge

2.5.1. Adding jQuery-UI to the project

2.5.2. Defining drop targets for items

2.5.3. Allowing items to be draggable

2.6. Deploying to meteor.com and using the fridge

2.7. Summary

Part 2: 3, 2, 1—impact!

3. Working with templates

3.1. Introduction to templates

3.2. Working with templates

3.2.1. The Blaze engine

3.2.2. Organizing template files

3.3. Creating dynamic HTML templates

3.3.1. Double and triple-braced tags (expressions)

3.3.2. Inclusion tags (partials)

3.3.3. Block tags

3.3.4. Helpers

3.4. Handling events

3.4.1. Template event maps

3.4.2. Event propagation

3.4.3. Preventing the browser’s default behavior

3.5. The template life cycle

3.6. Summary

4. Working with data

4.1. Meteor’s default data sources

4.1.1. What makes a data source reactive?

4.1.2. How reactive data is connected to functions

4.2. Building a house-sitter app

4.2.1. Setting up templates

4.2.2. Connecting to a database and declaring collections

4.3. Working with the Session object

4.3.1. The Session object

4.3.2. Using Session to store selected drop-down values

4.3.3. Creating a reactive context using Tracker.autorun

4.4. Working with MongoDB collections

4.4.1. Querying documents in MongoDB

4.4.2. Working with Meteor collections

4.4.3. Initializing a collection

4.4.4. Querying collections

4.4.5. Display collection data in a template

4.4.6. Updating data in a collection

4.4.7. Inserting new data into a collection

4.4.8. Removing data from a collection

4.5. Summary

5. Fully reactive editing

5.1. The reactive editing workflow

5.2. Reactive front ends vs. DOM manipulation

5.3. Staging changes in a local collection

5.4. Displaying collection data within a form

5.4.1. Adding array index information to an #each loop

5.5. Reactive updates using a local collection

5.5.1. Event map for the houseForm template

5.5.2. Event map for the plantFieldset template

5.6. Implementing a simple notifications system

5.6.1. Adding a notifications template

5.6.2. Adding a status property

5.6.3. Using a Session variable to trigger notifications

5.7. Summary

6. Users, authentications, and permissions

6.1. Adding users to an application

6.1.1. Adding password authentication

6.1.2. Registration and password reset

6.1.3. Setting up email

6.2. Authenticating users with OAuth

6.2.1. An introduction to OAuth

6.2.2. Integrating Facebook authentication

6.2.3. Integrating other OAuth providers

6.3. Managing user permissions, roles, and groups

6.3.1. Managing permissions with allow/deny

6.4. Summary

7. Exchanging data

7.1. Publications and subscriptions

7.1.1. publish() and subscribe()

7.1.2. Global subscriptions

7.1.3. Template-level subscriptions

7.1.4. Parameterizing subscriptions

7.1.5. Publishing aggregated data to a client-only collection

7.1.6. Turning an aggregation publication into a reactive data source

7.1.7. Limiting data visibility by user ID

7.2. Meteor methods

7.2.1. Removing the insecure package

7.2.2. Using methods to write data to collections

7.3. Summary

8. Routing

8.1. Routing in web applications

8.2. Client-side routing

8.2.1. Adding Iron.Router

8.2.2. Creating your first routes

8.2.3. Defining a layout depending on a route

8.2.4. Setting the data context depending on a route

8.2.5. Data subscriptions with Iron.Router

8.3. Advanced routing methods

8.3.3. Waiting for external libraries to load

8.3.4. Organizing routes as controllers

8.3.5. Extending the route process using hooks

8.3.6. Creating an Iron.Router plug-in

8.4. Server-side routing with a REST API

8.5. Summary

9. The Packages System

9.1. The foundation of all applications

9.2. Using Isopacks

9.2.1. Version Solver and semantic versioning

9.2.2. Finding packages

9.2.3. Adding and removing Isopacks

9.2.4. Updating packages

9.3. Using npm packages

9.4. Creating an Isopack

9.4.1. Creating a package

9.4.2. Declaring package metadata

9.4.3. Adding package functionality

9.4.4. Testing Isopacks using tinytest

9.4.5. Publishing

9.5. Summary

10. Advanced Server Methods

10.1. Reintroducing Node.js

10.1.1. Synchronous code

10.1.2. Asynchronous code

10.2. Asynchronous functions using fibers

10.2.1. Introducing multitasking to the event loop

10.2.2. Binding callbacks to a fiber with wrapAsync

10.2.3. Unblocking method calls for a single client

10.2.4. Creating fibers with bindEnvironment

10.3. Integrating external APIs

10.3.1. Making RESTful calls with the http package

10.3.2. Using a synchronous method to query an API

10.3.3. Using an asynchronous method to call an API

10.4. Uploading files to a collection

10.4.1. Uploading files to the database

10.5. Summary

Part 3: LEAVING THE CRATER

11. Building and debugging

11.1. The Meteor build process

11.1.1. Build stages

11.1.2. Running with the -production flag

11.1.3. Load order

11.1.4. Adding build stages via packages

11.1.5. Adding a custom build stage

11.2. Accessing running applications

11.2.1. Using the interactive server shell

11.2.2. Debugging using node-inspector

11.3. Creating browser applications

11.3.1. Application configuration using Meteor.settings

11.3.2. Building Meteor projects

11.4. Creating mobile applications

11.4.1. Hybrid apps with Cordova

11.4.2. Adding mobile platforms

11.4.3. Configuring mobile applications

11.4.4. Adding mobile functionality

11.5. Summary

12. Going into production

12.1. Preparing for production

12.1.1. Using version control

12.1.2. Testing functionality: the Velocity framework

12.1.3. Estimating and testing load

12.1.4. Server administration

12.1.5. Checklist

12.2. Setup and deployment

12.2.1. The simplest deployment: meteor.com

12.2.2. All-inclusive hosting: cloud providers

12.2.3. Full flexibility: manual setup

12.3. Connecting the pieces

12.3.1. Environment variables

12.3.2. Connecting Meteor to MongoDB

12.4. Scaling strategies

12.4.1. Active-passive high availability with redundancy

12.4.2. Single-component deployments

12.4.3. Redundancy and load balancing

12.4.4. Bulletproof availability

12.5. Summary

Appendixes

Appendix A: Installing Meteor

A.1. Prerequisites

A.2. Installing Meteor on Linux and Mac OS X

A.3. Installing Meteor on Windows

A.4. Running Meteor using Vagrant

Appendix B: The anatomy of MongoDB

B.1. The MongoDB components

B.1.1. mongod: databases and shards

B.1.2. mongos: query routing

B.1.3. mongoc: configuration servers

B.1.4. Replica sets

B.2. Setting up MongoDB

Appendix C: Setting up nginx

C.1. Load balancing with nginx

C.1.1. Installing nginx on Ubuntu

C.1.2. Installing on Debian 7 (Wheezy)

C.2. Configuring as a load balancer

C.2.1. Creating a site configuration file

C.2.2. Defining Meteor servers

C.2.3. Forwarding requests to the back-end servers

C.2.4. Activating the nginx site

C.3. Serving static content with nginx

C.3.1. Serving CSS and JavaScript

C.3.2. Serving media files and images

C.3.3. Enabling gzip compression

C.4. Setting up SSL with nginx

About the Technology

You might call Meteor a reactive, isomorphic, full-stack web development framework. Or, like most developers who have tried it, you might just call it awesome. Meteor is a JavaScript-based framework for both client and server web and mobile applications. Meteor applications react to changes in data instantly, so you get impossibly responsive user experiences, and the consistent build process, unified front- and back-end package system, and one-command deploys save you time at every step from design to release.

About the book

Meteor in Action teaches you full-stack web development with Meteor. It starts by revealing the unique nature of Meteor’s end-to-end application model. Through real-world scenarios, you’ll dive into the Blaze templating engine, discover Meteor’s reactive data sources model, learn routing techniques, and practice managing users, permissions, and roles. Finally, you’ll learn how to deploy Meteor on your server and scale efficiently.

What's inside

  • Building your first real-time application
  • Using MongoDB and other reactive data sources
  • Creating applications with Iron Router
  • Deploying and scaling your applications

About the reader

Readers need to know the basics of JavaScript and understand general web application design.

About the authors

Stephan Hochhaus and Manuel Schoebel are veteran web developers who have worked with Meteor since its infancy.


combo $44.99 pBook + eBook
eBook $35.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

An invaluable guide for any developer, from beginner to expert.

John Griffiths, UXGent.co

The only source you need to develop reactive, commercial-grade apps.

David DiMaria, Collective Sessions

The definitive resource on Meteor. The book's depth is unparalleled and the examples are real-world and comprehensive.

Subhasis Ghosh, ISACA