Node Program Online

Node Program Online

Node Program has been running since the summer of 2014. Next weekend, October 25-26, 2014 we’ll have another class which might be the last in-person course (register here)… because we launching Node Program Online on Udemy. Yes, that’s right! Last time we recorded the training and now the lectures, tests and interactive exercises will be available online!

Node Program Online in Draft

Node Program Online in Draft

Take a glimpse on this online course and comment on the titles such as:

  • From 0 to Hero with Node.js, MongoDB and Express.js
  • Beginner Node.js, MongoDB and Express.js
  • Master Node.js, MongoDB and Express.js in 2 days

So far, there are 33 lectures (~20 of them in HD video format) that will teach you all that Node Program teaches but without traveling to San Francisco, CA and at your own pace! One of the best things about video courses is that you can put lectures on pause or fast forward them.

NodeFrameworks.com Got GitHub Stats

Now our hand-picked registry of Node.js frameworks (NodeFrameworks.com) has GitHub statistics right on the website, so you don’t have to navigate back and forth when making a decision!

This is how it looks: each framework has a number (GitHub stars) next to its name. This serves as a social proof meaning the more people use the framework the more robust it is and the less bugs it has.

GitHub stats on NodeFrameworks.com

GitHub stats on NodeFrameworks.com

The buttons provided by the service called GitHub Buttons. The links to the frameworks’ GitHub, NPM, examples and other resources are hidden under the “i” icon.

Thank you Randson Oliveira for contributing and making pull requests!

Punishment for Becoming Better

Punishment for Becoming Better

If you do something for a living every day (i.e., you have a job) you have two choices:

  • Learn and become better: this is the default path for most people (it’s hard to do something over and over without getting better at it).
  • Stagnate and regress: this is actually harder than progress, and may require some subconscious proactive self-sabotage.

So everything is better if we automatically make progress, right? Not quite, because when we make progress, other people (including bosses) start to notice, and they then give/bring/order more of the same work—not a new type of work. Usually it’s the same stuff you’ve been doing already (and for the same money), because management doesn’t want to lose a good producer. I call this punishment for becoming better.

Continue reading

Node Octoberfeast: 5 Books for $9.87

Node Octoberfeast: 5 Books for $9.87

Node Octoberfeast deal is five (5!!!) books on Node.js and JavaScript plus an Express.js v4.x cheatsheet.. for just $9.87!!! Buy at gum.co/sxvV.

Hurry up—the deal expires on October 2 6pm PT, 2014!!!

The list of books as follows:

  1. Rapid Prototyping with JS: Agile JavaScript Development
  2. JavaScript and Node FUNdamentals: A Collection of Essential Basics
  3. Oh My JS: The Best JavaScript Articles
  4. Express.js Guide: The Comprehensive Book on Express.js
  5. Introduction to OAuth with Node.js: Twitter API OAuth 1.0, OAuth 2.0, OAuth Echo, Everyauth and OAuth 2.0 Server Examples

Buy them all at gum.co/sxvV.

 

 

Secret Express.js Settings

Secret Express.js Settings

Express.js is one of the top Node.js frameworks out there. It was used in the overwhelming majority of projects that I’ve encountered since I began working with Node.js in 2011. One of the main selling points and key differentiators is the framework’s configurability. However, while writing Express.js Guide and Pro Express.js, I discovered a few secret settings never mentioned in their documentation (Figure 1).

These undocumented settings are:

  • json spaces
  • etag
  • query parser
Figure 1: Documented Express.js Settings

Figure 1: Documented Express.js Settings

Let’s take a closer look at each one of them. This article is applicable to Express.js versions 3.x and up to 4.8.1 which is the latest as of this writing.

json spaces

When you use the Express.js’ method response.json() to send back to the client’s JSON data, you benefit from special parameters: replacer and spaces. The former is documented on the website while the latter is not. Under the hood, these parameters are passed to the JSON.stringify() function (MDN docs). JSON.stringify() is a widely used function for transforming native JavaScript/Node.js object into strings.

The spaces option modifies JSON output exactly as described in the stringify() documentation—“Causes the resulting string to be pretty-printed”. For example, you can set the spaces value to 4 to indent each level with four spaces:

// ... Express.js app instantiation 
app.set('json spaces', 4);
// ... Express.js app routes

The statement above will produce indentation as shown in Figure 2.

Figure 2: JSON output with replacer and spaces set

Figure 2: JSON output with replacer and spaces set

On the other hand, when you use response.json() with default settings (probably to minimize the size), the output will look less readable (as shown in Figure 3).

Figure 3: JSON output without spaces set

Figure 3: JSON output without spaces set

My opinion is that spaces set to 2 can be used when the application is in development mode (app.get('env')=='development').

etag

ETag or entity tag is one of the caching mechanisms. The way it works is akin to putting a unique identifier for the content on a given URL. In other words, if content doesn’t change on a specific URL, the etag will remain the same and the browser will use the cache.

In Figure 4, you can see an example of the ETag response header.

Figure 4: ETag header is enabled

Figure 4: ETag header is enabled

If someone doesn’t know what it is or how to use it, it’s better to leave the Express.js etag setting alone, which means that by default the ETag will be enabled. Otherwise, to disable it:

// ... Express.js app instantiation 
app.disable('etag'); 
// ... Express.js app routes

This will eliminate ETag response header as shown in Figure 5.

Figure 5: ETag header is enabled

Figure 5: ETag header is enabled

By default, Express.js uses “weak” ETag. Other possible values are:

  • true: weak ETag, e.g., app.enable('etag'); that produces a response with ETag as shown in Figure 4
  • false: no ETag at all (IMHO not recommended), e.g., app.disable('etag'); that produces a response without ETag as shown in Figure 5
  • weak: weak ETag, e.g., app.set('etag', 'weak');
  • strong: strong ETag, e.g., app.set('etag', 'strong');

An identical strong ETag guarantees the response is byte-for-byte the same, while an identical weak ETag indicates that the response is semantically the same.

query parser

Query, or query string, is a data sent in the URL after the question mark sing, e.g., http://anywherelib.com?name=value&name2=value2. Express.js automatically includes the parsing of such query strings in the form of a middleware.

The default value for query parser is extended which will use the qs module.

All possible values for the query parser setting are:

The usage example with disabled query parser middleware as follows:

// ... Express.js app instantiation 
app.set('query parser', false);
// ... Express.js app routes

The usage example with qs query parser middleware, as follows:

// ... Express.js app instantiation 
app.set('query parser', `extended`);
// ... Express.js app routes

It’s possible to pass your own function as an argument. In this case, your custom function will be used for parsing instead of parsing libraries like qs. For example,

// ... Express.js app instantiation 
app.set('query parser', function(value, options){
  // ... value is a query string, process it here
});
// ... Express.js app routes

Conclusion

As usual with undocumented features, use them with caution. Also be aware of the framework’s versions (this article was tested with 4.8.1).

This text is part of Azat’s upcoming book—Pro Express.js by Apress. If you liked this article, make sure to opt-in for the webapplog.com newsletter.

The Foundation: Starting from Nothing

The Foundation: Starting from Nothing

Last year, at about this same time, I discovered The Foundation podcast. I was vacationing in Mexico and stumbled on it via Pat Flynn’s Smart Passive Income—a hyper-popular online infopreneur. I downloaded and listened to many similar podcasts on online business, but The Foundation surprised me in the magnitude of its guests’ success stories. These weren’t the product of a few niche blogs, life coaching and ebooks, but six figures per month (and up) marketing and SaaS companies.

Continue reading

Time to Up Your Node.js Skills

Node Program: Intensive Node.js, MongoDB and Express.js Course in The Bay Area

Are you a software engineer who wants to master an effective and fun-to-use, new platform Node.js? Is your goal to stay on top of the curve with cutting-edge technology, and to stay ahead of the competitive software engineering industry by delivering high quality products faster?

But that’s a real challenge. New technologies are poorly documented, and the best practices are often unknown. There’s a serious risk to waste valuable time pursuing the wrong stack or pattern when you read amateurish blog posts and outdated books.

The good news is that there are companies that have run Node.js in high-scale production environments for years (Storify-where I worked before it was acquired—is one of them). That’s the expertise you can tap into.

Most likely it’s not your fault that your company or team didn’t want to invest in Node.js stack a few years ago. The circle of adopters was small, because most of the early technologies are controversial and unstable. This is not the case with Node.js anymore! eBay, PayPal, Groupon, Walmart, DocuSign, and many other large corporations have all adopted Node.js. So this is a great time to jump on the stack before it becomes mainstream!

Not all languages and platforms are created equal. Time proves again and again that engineers who cling to old technology become hard to employ. Every programmers’ and businesses’ enemy is not staying up-to-date on technology. And nowadays with the increasing information overload, it becomes more and more challenging. That’s why we started Node Program, a two-day intensive hands-on Node.js, MongoDB and Express.js training, so you can keep growing in the most efficient way!

This training was conceived in 2012;, constantly taught, and improved since then. Overall, almost a hundred people went through it in organizations like: Cisco, Twitter University (Marakana), General Assembly, pariSOMA, and others. Every student got out of this program more than he/she expected (testimonials). And at the end of this course, I promise you that you will walk away with a few Node.js applications, developed by you.

In addition to the extensive core curriculum (full description)—which was battle tested in the Amazon.com Best Selling books in the Client Server category— you will be exposed to some tips from the trenches. Here are just some of the tipsguidelines and inclusions:

  • Why not committing Node.js modules to your repository is dangerous
  • Why Jade is hard to learn but is one of the most efficient and powerful template engines to master
  • How to escape the madness of levels upon levels of nested callback code
  • Why using the default maxSockets value is a bad idea
  • The best debugging tools that the Node.js professionals use
  • What are the hottest new frameworks that might replace Express.js as the de-facto choice
  • Why the Node Package Manager code was written without semicolons

We’ve put together the best information in the simplest way to help you learn about Node.js, Express.js and MongoDB. The only way to get the information like that is to spend years actively working with the Node.js stack, going to conferences, and constantly researching… or to attend the two-day Node Program class. Why take the long route of learning? Do you really have the time to study via trials&errors, source code, books, blogs and free online documentation? Basically, we are helping you to take a shortcut, save time, avoid frustration, and costly mistakes by using the best practices available.

The next class will be held on September 27–28, 2014—next weekend! We have a limited number of seats, so act now.

You can register for our in-person two-day course in San Francisco on September 27–28 at http://nodeprogram.com.

PS: Do you live in a different state? At the last class, we had a student who flew from Florida! But if flying is not an option, send us a note via the form at http://nodeprogram.com, and we might have a solution for you.

MongoUI: Real-Time MongoDB Admin Web Interface (a la phpMyAdmin in Node.js)

MongoUI: Real-Time MongoDB Admin Web Interface is Your Life Ring

MongoUI is a real-time web interface for Node.js and MongoDB written with DerbyJS—a real-time full-stack web framework. It’s a app that can be run locally and on the server. Similarly, you can view and manipulate data in a local or remote database. The MongoUI project is in beta so use caution, and please contribute your feedback.

MongoUI on NPM: https://www.npmjs.org/package/mongoui

MongoUI on GitHub: https://github.com/azat-co/mongoui

MongoUI description (this page): http://webapplog.com/mongoui

MongoUI features include:

  • Switch databases and collections
  • Search by field value (string, number, ObjectId)
  • Save search / filter results as a bookmark (each URL has a query)
  • Edit any fields’ values in a real-time editor
  • Get raw JSON objects

Here’s a one-and-a-half-minute video that shows filtering, editing, and switching collections:

Direct link to the YouTube video: http://youtu.be/l8Rfpow0f9A.

Continue reading

You’re Wasting $10,000 to $130,000!

Yes, you’ve read it right! You can be wasting anywhere from $10,000 to $130,000 right now by not sharing your technical expertise with others. In other words, you can keep the money by writing about tech. All this is doable while keeping your full-time job. You think it’s impossible? That programmers like to pay nothing for resources? Think again, because hundreds of authors already did it, with outliers like Nathan Barry and Sacha Greif making six figures. The best part is that (after the info product is ready) it’s mostly passive income!

Continue reading

CoffeeScript: The Good Parts

CoffeeScript: The Good Parts at QConNY 2014

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.

My own story is going from making fun to loving it after a year developing an enterprise product. As with the famous JavaScript: The Good Parts book, we’ll look at what’s good in CoffeeScript (and it’s quirks too).

The CoffeeScript: The Good Parts talk will share experiences from the trenches of using CoffeeScript in production. This talk was first presented at the QCon New York 2014 conference. You can watch it on their InfoQ page. Or you can watch the video recorded at DevBootCamp meetup in San Francisco, CA:

Direct link to Youtube is https://www.youtube.com/watch?v=WX5Y6Dq1OHE.
Continue reading