CoffeeScript: The Good Parts

It’s not a secret that the topic of CoffeeScript is controversial to say the least. Many reputable JavaScript and Node.js developers just hate CoffeeScript, but there are lessons we can all learn from its good parts! However, many developers just won’t go back to plain JavaScript after building something relatively serious with CoffeeScript.

Continue reading “CoffeeScript: The Good Parts”

Introduction to OAuth with Node.js and Online Subscription—RELEASED!

The much-needed Introduction to OAuth with Node.js mini-book is released!

Introduction to OAuth with Node.js
Introduction to OAuth with Node.js: Twitter API OAuth 1.0, OAuth 2.0, OAuth Echo, Everyauth and OAuth 2.0 Server Examples

Get your PDF, EPUB, MOBI copy here –> gum.co/hRyc
or sign up for Node.js and JavaScript Mastery Online here.

The online bundle has five (5!) books. Here’s the list of available books. It’s a $50+ value for only $4.87/mo.

Node.js and JavaScript Mastery Online: Colored code examples—paste into your projects!
Node.js and JavaScript Mastery Online: Colored code examples—paste into your projects!

If you read all the books in less than a month—great! Just cancel the subscription. But most readers prefer to keep it just so they have a handy reference when they need it.

The Introduction to OAuth book includes:

  • OAuth 1.0
  • OAuth Echo
  • OAuth 2.0
  • OAuth 1.0 Sign in with Everyauth
  • OAuth 2.0 Server

A typical modern web applications has to communicate with other services. Even if it’s your own service or application. This is usually done via an open standard for authorization or OAuth. Therefore, the ability to use OAuth in your work is paramount!

There are standards, specifications and fancy diagrams, and it’s useful to read them as the first step. However, developers often need hands-on experience to acquire the full understanding and confidence.

Introduction to OAuth in Node.js is a concise practical book that will help you to get started with OAuth 1.0, 2.0, Echo and implement a Sign in with Node.js using Twitter API (and hopefully any other) authentication.

We’ll go through the three main authentication methods utilizing minimalistic oauth module to explain basics, then use extensive everyauth with an Express.js app.

Get your PDF, EPUB, MOBI copy here –> gum.co/hRyc
or sign up for Node.js and JavaScript Mastery Online here.

Intro to OAuth with Node.js: OAuth 1.0 (One-Legged)

This text is part of Introduction to OAuth with Node.js mini-book which is available at gum.co/hRyc.

Introduction to OAuth with Node.js
Introduction to OAuth with Node.js: Twitter API OAuth 1.0, OAuth 2.0, OAuth Echo, Everyauth and OAuth 2.0 Server Examples

Let’s start with good old OAuth 1.0. The way it usually works is as follows:

  1. For the first time, when we authorize a user to use our app, we need to perform extra work and obtain access token and secret (three-legged).
  2. You store these values for each user in your application.
  3. Then, on subsequent requests, things become much simpler. We construct auth headers and make HTTP requests (one-legged).

Continue reading “Intro to OAuth with Node.js: OAuth 1.0 (One-Legged)”

Seven Things You Should Stop Doing with Node.js

Inspired by 5 Things You Should Stop Doing With jQuery by Burke Holland, I decided to open a discussion and highlight seven things you should immediately stop doing with Node.js:

  1. Stop using callbacks
  2. Stop using * for versions
  3. Stop using console.log for debugging
  4. Stop using GET and POST for everything
  5. Stop using semicolons
  6. Stop using comma-first style
  7. Stop limiting your connections with default maxSockets value

Continue reading “Seven Things You Should Stop Doing with Node.js”

Practical Node.js TOC

As the Apress team of technical reviewers and copy editors and I make progress on the Practical Node.js manuscript, the date of the publication approaches fast. Last time I checked it was June 2014.

Practical Node.js: Building Real-world Scalable Web Apps
Practical Node.js: Building Real-world Scalable Web Apps

Many people ask me: how is the process compared to self-publishing? Is it worth the hassle?

So far, I can say only good things about my editors and the process of traditional publishing itself. I’m impressed about so many things I’ve already learned about structuring and technical writing. I feel like it enormously improved my style. There is more on this in my new meta book&resource ProgWriter.

As a sneak peek, here’s the tentative Table of Contents for the Practical Node.js book:

  1. Setting up Node.js and Other Essentials
  2. Using Express.js to Create Node.js Web Apps
  3. TDD and BDD for Node.js with Mocha
  4. Template Engines: Jade and Handlebars
  5. Persistence with MongoDB and Mongoskin
  6. Using Sessions and OAuth to Authorize and Authenticate Users in Node.js Apps
  7. Boosting Your Node.js Data with the Mongoose ORM Library
  8. Building Node.js REST API Servers with Express.js and Hapi
  9. Real-time Apps with WebSockets, Socket.IO and DerbyJS
  10. Getting Node.js Apps Production Ready
  11. Deploying Node.js Apps
  12. Publishing Node.js Modules and Contributing to Open Source

The good thing is that people who want to get the book first don’t have to wait ’til the book is released. They can pre-order the book on Amazon, or even better get access to the alpha version at Apress!

The alpha version will be release chapter by chapter starting in the next few weeks!

Migrating Express.js 3.x to 4.x: Middleware, Route and Other Changes

Express.js 4 is the latest (as of May 2014) version of the most popular mature and robust Node.js framework for web apps, services and APIs. There are some breaking changes going from 3.x to 4.x, so here’s a brief migration guide:

Continue reading “Migrating Express.js 3.x to 4.x: Middleware, Route and Other Changes”

Express.js 4, Node.js and MongoDB REST API Tutorial

Usually good things don’t stay the same, so our tutorial on building a JSON REST API server with Node.js and MongoDB using Mongoskin and Express.js, and testing it with Mocha and Superagent, has became a bit outdated with the new Express.js 4 version release. Here’s a brand new, revisited tutorial for Express.js 4, Node.js and MongoDB (Mongoskin) free-JSON RESTful API server.

The code for this new tutorial is available at github.com/azat-co/rest-api-express (master branch). The old tutorial’s code for Express 3.x, is still working and in the express3 branch.

Express.js 4 and MongoDB REST API Tutorial consists of these parts:

  1. Node.js and MongoDB REST API Overview
  2. REST API Tests with Mocha and Superagent
  3. NPM-ing Node.js Server Dependencies
  4. Express.js 4.x Middleware Caveat
  5. Express.js and MongoDB (Mongoskin) Implementation
  6. Running The Express.js 4 App and Testing MongoDB Data with Mocha
  7. Conclusion and Further Express.js and Node.js Reading

Instead of TL;DR:

If you’re only interested in a working code from the repository and know what to do, here are brief instructions on how to download and run the REST API server:

$ git clone git@github.com:azat-co/rest-api-express.git
$ npm install
$ node express.js

Start MongoDB with $ mongod. Then, in a new terminal window run the Mocha tests:

$ mocha express.test.js

Or, if you don’t have mocha installed globally:

$ ./node_modules/mocha/bin/mocha express.test.js

Node.js and MongoDB REST API Overview

This Node.js, Express.js and MongoDB (Mongoskin) tutorial will walk you through writing the test using the Mocha and Super Agent libraries. This is needed for a test-driven development building of a Node.js free JSON REST API server.

The server application itself will utilize Express.js 4.x framework and Mongoskin library for MongoDB. In this REST API server, we’ll perform create, read, update and delete (CRUD) operations and harness Express.js middleware concept with app.param() and app.use() methods.

First of all, make sure you have MongoDB installed. You can follow the steps on the official website.

We’ll be using the following versions of libraries:

  • express: ~4.1.1
  • body-parser: ~1.0.2
  • mongoskin: ~1.4.1
  • expect.js: ~0.3.1
  • mocha: ~1.18.2
  • superagent: ~0.17.0

If you try to attempt to use later or older versions the code might not work. :-(

Continue reading “Express.js 4, Node.js and MongoDB REST API Tutorial”

Getting Published as a Programmer: The Practical Node.js Story

This is the story about how I got my first publishing deal, what this book is about, and what problems I encountered along the way.

TL;DR: This is the story about how I got my first publishing deal, what this book is about, and what problems I encountered along the way.

I spent last weekend sitting in an awesome new coffee shop in Oakland, typing up the last two chapters of my Practical Node.js manuscript. The book is scheduled for release by the UK-based technical publisher Apress in the late spring.

I started writing the manuscript in October 2013. I devoted my weekends and holidays to it (as so many entrepreneurs and writers do). The fact that I smartly had a few example apps and some drafts written — some of them for my blog, others for proposals to Pragmatic (declined!) — helped to speed things up. (Needless to say, in publishing rejection is a common thing and often an opportunity to get better.) However, the writing itself wasn’t the hardest part. Here’s the short story why.

Continue reading “Getting Published as a Programmer: The Practical Node.js Story”

Blog Express.js Web Application Example

Here is one of the main examples that is featured in the book: the Blog application built with Express.js, MongoDB and Mongoskin. The application is subject to change, but if you’re an intermediate or advance Node.js programmer, go ahead and poke the source code, kick the tires of the server. It’s not a Ghost blogging platform, but blog-express can give valuable practical tips on how to implement:

Session-based authentication
Express.js middleware authorization
MVC-like pattern using lightweight MongoDB library called Mongoskin
REST API server
Express.js routes organization
Jade and server-side rendering

For the past few weeks, I’ve been writing a new book on Node.js. Hence the lack of new posts. This time, the book encompasses virtually all of the practical aspects of web development using Node.js: authentication, authorization, OAuth with third-party service providers, testing, libraries, frameworks, databases, ORMs and MVC-like patterns. In other words, if you have to read only one book on Node.js (which is not a good advice, but let’s assume), this will be the book that you have to read. :-)

The title and the alpha sign up are in secret for now (subscribe to get the news faster). The book is due in early spring 2014.

Here is one of the main examples that is featured in the book: the Blog application built with Express.js, MongoDB and Mongoskin. The application is subject to change, but if you’re an intermediate or advance Node.js programmer, go ahead and poke the source code, kick the tires of the server. It’s not a Ghost blogging platform, but blog-express can give valuable practical tips on how to implement:

  • Session-based authentication
  • Express.js middleware authorization
  • MVC-like pattern using lightweight MongoDB library called Mongoskin
  • REST API server
  • Express.js routes organization
  • Jade and server-side rendering
Blog Express.js App Home Page
Blog Express.js App Home Page

GitHub: http://github.com/azat-co/blog-express

Node.js FUNdamentals: A Concise Overview of The Main Concepts

Node.js is a highly efficient and scalable non-blocking I/O platform that was build on top of Google Chrome V8 engine and its ECMAScript. This means that most front-end JavaScript (another implementation of ECMAScript) objects, functions and methods are available in Node.js. Please refer to JavaScript FUNdamentals if you need a refresher on JS-specific basics.

Note: This text is a part of upcoming ebook JavaScript and Node FUNdamentals: A Collection of Essential Basics.

Node.js is a highly efficient and scalable non-blocking I/O platform that was build on top of Google Chrome V8 engine and its ECMAScript. This means that most front-end JavaScript (another implementation of ECMAScript) objects, functions and methods are available in Node.js. Please refer to JavaScript FUNdamentals if you need a refresher on JS-specific basics.

Continue reading “Node.js FUNdamentals: A Concise Overview of The Main Concepts”

Express.js and Mongoose Example: Building HackHall

Note: This text is a part of the Express.js Guide: The Comprehensive Book on Express.js.

The HackHall project was written using Backbone.js and Underscore for the front-end app, and Express.js, MongoDB via Mongoose for the back-end REST API server.

Continue reading “Express.js and Mongoose Example: Building HackHall”

Q&A: ImageMagick and Code Organization in Express.js

We continue with the Q&A from our readers. This is a question from Ian, the reader of Rapid Prototyping with JS.

We continue with the Q&A from our readers. This is a question from Ian, the reader of Rapid Prototyping with JS.

Continue reading “Q&A: ImageMagick and Code Organization in Express.js”

Express.js FUNdamentals: An Essential Overview of Express.js

Note: This text is a part of upcoming ebook JavaScript and Node FUNdamentals: A Collection of Essential Basics.

Express.js is an amazing framework for Node.js projects and used in the majority of such web apps. Unfortunately, there’s a lack of tutorials and examples on how to write good production-ready code. To mitigate this need, we released Express.js Guide: The Comprehesive Book on Express.js. However, all things start from basics, and for that reason we’ll give you a taste of the framework in this post, so you can decide if you want to continue the learning further.

Continue reading “Express.js FUNdamentals: An Essential Overview of Express.js”

Foreword to Express.js Guide: The Comprehensive Book on Expresss.js

Dear reader, you are holding a book which will open you to understanding and fluent usage of the Express.js framework – standard de facto in web application programming on Node.js. And I would especially recommend this book because it was written by a practicing engineer, one who has a comprehensive knowledge about the full stack of web application development and Express.js in particular…

Dear reader, you are holding a book which will open you to understanding and fluent usage of the Express.js framework – standard de facto in web application programming on Node.js. And I would especially recommend this book because it was written by a practicing engineer, one who has a comprehensive knowledge about the full stack of web application development and Express.js in particular.

Continue reading “Foreword to Express.js Guide: The Comprehensive Book on Expresss.js”

ExpressWorks: an Automated Express.js/Node.js Workshop and Tutorial

ExpressWorks is an automated Express.js/Node.js workshop.

TL;DR: ExpressWorks is an automated Express.js/Node.js workshop.

Continue reading “ExpressWorks: an Automated Express.js/Node.js Workshop and Tutorial”

Q&A: Thank You Web App, Express.js and Emails

I recently received a question from Joanne Daudier. She is a up and coming web developer, middle term student at a JS/Node.js bootcamp called RefactorU and a reader of Express.js Guide. This is what she wrote:

Hi Azat:

I skimmed over your book today. I feel like it is a bit advanced for me since I’m just learning Express. I do have a few questions for you though.

I recently received a question from Joanne Daudier. She is an up and coming web developer, middle term student at a JS/Node.js bootcamp called RefactorU and a reader of Express.js Guide. This is what she wrote:

Continue reading “Q&A: Thank You Web App, Express.js and Emails”

Solving Programming Problems

Programming problems are not that much different from mathematics or physics problems. There are usually an input and an output to which someone needs to arrive by providing an algorithm. This algorithm is typically a function or series of functions.

Programming puzzles and toy problems are good exercises to sharpen skills and prepare for technical interviews. No wonder that more and more online coding schools (e.g., CodeAcademy) make those metal workouts main staple of their courses.

Beginner programmers might benefit by applying these steps to their process of solving a programming problem:

Programming problems are not that much different from mathematics or physics problems. There are usually an input and an output to which someone needs to arrive by providing an algorithm. This algorithm is typically a function or series of functions.

Programming puzzles and toy problems are good exercises to sharpen skills and prepare for technical interviews. No wonder that more and more online coding schools (e.g., CodeAcademy) make those metal workouts main staple of their courses.

Beginner programmers might benefit by applying these steps to their process of solving a programming problem:

Continue reading “Solving Programming Problems”