Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Express.js Blueprints
Table of Contents
Express.js Blueprints
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. Building a Basic Express Site
Setting up Express for a static site
Saying Hello, World in Express
Jade templating
Local user authentication
User object modeling
Introducing Express middleware
Setting up passport
Registering users
Authenticating users
OAuth with passport
Adding OAuth to user model
Getting API tokens
Third-party registration and login
Profile pages
URL params
Profile templates
Testing
Introducing Mocha
Testing API endpoints
Automate builds and deploys
Introducing the Gruntfile
Continuous integration with Travis
Deploying Node.js applications
Summary
2. A Robust Movie API
Folder structure and organization
Responding to CRUD operations
Retrieving an actor with GET
Creating a new actor with POST
Updating an actor with PUT
Removing an actor with DELETE
Object modeling with Mongoose
Generating unique IDs
Validating your database
Extracting functions to reusable middleware
Testing
Summary
3. Multiplayer Game API – Connect 4
Modeling game state with Mongoose
Creating a new game
Input validation
Getting the game state
Joining a game
Playing the game
Testing for a tie
Summary
4. MMO Word Game
Gameplay
Real-time application overview
Keeping track of active users
Schema design
User schema
User join
Promises
The then and catch method
Chain multiple Promises
Prevent duplicates
User leaves the game
Show all active users
The words – Subdocuments
Validate input
Dealing with race conditions
Test case to test race conditions
Socket.IO
Socket handshaking, user join
Adding and pushing updates to clients
Launch Socket.IO applications
Test Socket.IO applications with the Socket.IO client
Debug Socket.IO with Chrome Developer Tools
Summary
5. Coffee with Strangers
Code structure
Defining routes
Persisting data
Exception handling
Naive pairing
Notes about tests
Considering user history
Optimizing for distance
E-mail follow up
Periodical tasks with node-cron
Summary
6. Hacker News API on Koa.js
Generator syntax
Middleware philosophy
Context versus req,res
The link model
The link routes
Tying it together
Validation and error handling
Update route
Let's perform some tests
Parallel requests
Rendering HTML pages
Serving static assets
Summary
A. Connect 4 – Game Logic
Index
← Prev
Back
Next →
← Prev
Back
Next →