The JavaScript blog.


libraries node email modules network notifications vm automation

Node Roundup: watch-network, MailDev, node-notifier

Posted on .


If you use something like Docker or Vagrant and want to listen for file notifications over the network, then watch-network (GitHub: efacilitation/watch-network, License: MIT, npm: watch-network) by Johannes Becker might come in handy. It can be used with Gulp, so you could run Gulp tasks when a specific network notification comes in.

Here's a basic example:

var watch = WatchNetWork({  
  configs: [{
    patterns: 'lib/*.coffee',
    tasks: 'something:important',
    onLoad: true

watch.task('something:important', function(changedFiles) {  
  // ..


Here's the use-case that Johannes described:

Scenario: You use Vagrant/VirtualBox in your workflow to have services and configurations in an encapsulated environment. For developing purposes you now sync a local directory into the VM using vboxfs, nfs, rsync or similar. In your VM you want to use watcher facilities for developing-concerns, but for some reason triggering inotify over the network seems to be troublesome or unreliable.



If you've ever felt like handling emails in web applications is messy, and you don't feel like your emails are as good as they could be, then you're not alone! I always feel like emails are annoying to develop, so I thought MailDev (GitHub: djfarrelly/maildev, License: MIT, npm: maildev) looked interesting. This module helps you test your project's generated emails during development with a responsive web interface. It has a Node API, and there's even a REST API so you could integrate it with other services.

Emails are displayed with WebSockets, so you don't have to keep refreshing, and it'll show HTML, text, and attachments.

I currently send all the generated emails to a temporary directory, then open them up when I need to. MailDev seems like a much better solution.


Mikael Brevik sent in node-notifier (GitHub: mikaelbr/node-notifier, License: MIT, npm: node-notifier), in response to the recent mention of trayballoon. Node-notifier tries to smooth out the differences between each platform, so you can use notification features that are present on all platforms more easily. It also supports actions on notifications.

Mikael notes that it works with node-webkit, which is cool if you're making Node desktop apps, and it supports the following notification systems:

  • Mac: Notification Center, Growl
  • Windows: Toasters, trayballoon
  • Linux: notify-osd

Here's an example:

var notifier = require('node-notifier');  
  'title': 'My notification',
  'message': 'Hello, there!'


libraries node email modules scraping windows

Node Roundup: Mailman, trayballoon, unembed

Posted on .


Mailman (GitHub: vdemedes/mailman, License: MIT, npm: mailman) by Vadim Demedes is a module for sending emails that supports generators. It uses nodemailer for sending email, and consolidate.js for templates, which means it supports lots of different template languages.

Generators are used for sending emails, so you can do this:

var mail = new UserMailer({ to: 'vadim@example.com' }).welcome();  
yield mail.deliver();  

Mailman expects a specific directory layout for views, but the added level of structure might help if you've got a big mess of email-related code in your current projects.



trayballoon (GitHub: sindresorhus/trayballoon, License: MIT, npm: trayballoon) by Sindre Sorhus is a module for showing system tray balloons in Windows. You can set the text and image to display, and a callback that will run when the balloon disappears:

  text: 'Unicorns and rainbows'
  icon: 'ponies.ico',
  timeout: 20000
}, function() {
  console.log('Trayballoon disappeared');

It also has a command-line tool which you could use to display notifications when things like tests fail. trayballoon works by bundling an executable called nircmdc.exe which is called with child_process.spawn.


Given some "embed code" for sites like YouTube and Vimeo, unembed (GitHub: colearnr/unembed, License: MIT, npm: unembed) by Prabhu Subramanian will extract the markup and produce a JSON representation. This might be useful if you're scraping sites that use embed codes, like blogs and forums.

I've never thought of applying the tiny modules philosophy to scraping, but it seems like a great way of sharing all of those hacks we use to extract data in a more structured way.


libraries testing node email modules npm jasmine

Node Roundup: npm CLI Roadmap, Nodemailer, Jasmine-Utils

Posted on .

npm CLI Roadmap

On the npm blog, there's a post about the command-line tool's roadmap:

The first piece of redesign work we're tackling is the npm cache. ... The next goal is to turn it into a module with no dependencies on the rest of npm or npmconf and to test the heck out of it. As npm moves to being a part of the toolchain of front-end developers (who are more interested in shipping features than figuring out what's going on with their OS), it's time to work on making npm easier to understand when things go wrong.

The article also mentions a better search interface, which I'd like to see because the current CLI search implementation is inflexible. It's interesting to read about how the project is evolving away from Isaac's original lightweight implementation intended for experts -- the team behind the project has recognised that npm is used by a diverse range of developers.


Nodemailer (GitHub: andris9 / Nodemailer), License: MIT, npm: nodemailer 1.0 is out! This is a complete rewrite, and partly breaks backwards compatibility so you may need to upgrade carefully:

The new version allows you to write custom plugins for manipulating the outgoing messages. It is also possible to send huge attachments with ease (in the size of tens of gigabytes) thanks to the Streams2 support - even though no one probably needs to send such attachments since probably no e-mail server would accepts these.


Jasmine-Utils (GitHub: mjeanroy / jasmine-utils, License: MIT, npm: jasmine-utils) by Mickael Jeanroy is a set of custom matchers for Jasmine. They're grouped around types, like toBeABoolean and toBeDateBefore. Methods are included for booleans, strings, arrays, dates, objects and functions:

it('should check that an object contains keys', function() {  
  var obj = {
    id: 1,
    name: 'foo'

  expect(obj).toHaveKeys('id', 'name');
  expect(obj).not.toHaveKeys('foo', 'bar');

It also includes some handy spy methods, like jasmine.spyAll and jasmine.spyIf. These allow objects to be watched to ensure the expected methods are run.

The project includes a huge amount of matchers, so if you're using Jasmine you may want to check it out.


node email modules npm rest

Node Roundup: newspeak, CatchMe, Catnap

Posted on .


newspeak (GitHub: yoshuawuyts / newspeak, License: MIT, npm: newspeak) by Yoshua Wuyts is a module inspired by Mozilla's L20n project:

L20n is a new localization framework developed by Mozilla for the Web. It allows localizers to put small bits of logic into localization resources to codify the grammar of the language.

The following example is a small pluralisation helper:

var newspeak = require('newspeak');  
var l20n = newspeak({ language: 'nl', gender: 'male' });

var data = {  
  users: function(obj) {
    if (0 === obj.count) return 'nobody';
    if (1 === obj.count) return 'someone';
    return '{{count}} people';

l20n.register({ nl: data });  
l20n.get('users', { count: 3 });  


CatchMe (GitHub: Pentiado / catch-me, License: MIT, npm: catch-me) by Paweł Wszoła is another Node SMTP server that captures emails. This one has a nice web interface, and can validate email with Campaign Monitor.

It accepts command-line arguments for defining the web and SMTP ports: catchme --mailPort 1234 --appPort 4321


Catnap (GitHub: mikaa123 / catnap, License: MIT, npm: catnap) by Michael Sokol is an Express-compatible module for generating REST resources:

var makeResource = require('catnap').makeResource;

var userResource = makeResource('user', '/users/:userId')  
  .representation(function(user) {
    // The default representation. Returns a full representation of user
    return user;
  .representation('partial', function(user) {
    // A named representation that returns a partial representation
    return pick(user, 'username', 'email');
  .get(function(req, res) {
    // Action methods take standard middleware.
    User.findOne({ _id: req.params.userId }, function(err, user) {
      user && res.send(200, userResource(user));

There's a wiki with documentation that explains how the module relates to Roy Fielding's dissertation:

So in other words, a resource is some service that lives at a URI and that has one or more representations. In order to interact with a resource, we need to use an HTTP request method, you know, GET, POST, PUT, PATCH and DELETE. These methods have a lot of semantics baked in! For example, when we GET /users/123, we are asking for the representation of the user who's id is '123'. This HTTP transaction (request-response) is called an action.


node email modules npm servers

Receiving Emails with Node

Posted on .

One of the things I like to evangelise about Node is the fact it's good for creating any network servers, not just web stuff. Florent Galland sent in Mailin (GitHub: Flolagale / mailin, License: MIT, npm: mailin), which allows your web apps to receive inbound emails. What's cool about Mailin is it runs as an SMTP server, so rather than having to configure a mail server you can just use Mailin by itself.

Mailin's homepage has a cool demo that allows you to send it an email and see it appear on the page. This works using Mailin's webhook.


You can configure the webhook when the server is started:

mailin --webhook http://example.com/incoming_emails  

The documentation explains how to install it with authbind for safe binding to port 25, otherwise sudo or a root user would be required.

The documentation also mentions optional spam detection support.

Mailin is built with the simplesmtp module. This provides a Node API for building SMTP servers. It has an API that should be familiar to anyone who has written HTTP code with Node:

simplesmtp.createSimpleServer({ SMTPBanner: 'My Server' }, function(req) {  

simplesmtp even supports connection pools, and TLS. I love the idea of using Node for servers that I can customise, but I'm not a security expert so I don't know what the implications of using these modules in production might be. Maybe it's time I read Node Security!