DailyJS

DailyJS

The JavaScript blog.


Tagconnect
Featured

libraries node modules express connect iojs json-schema

Node Roundup: Unifying Node with io.js, JSON Object to JSON Schema, conveyor-belt

Posted on .

StrongLoop on Unifying Node with io.js

The StrongLoop blog has a post by Issac Roth about the unification of Node and io.js:

Unification is something you can help with! The io.js repository and the Node Google group are open to all. Get involved, post issues and comments, let people know your ideas and solutions. Tell people where you stand on the issue. I've worked with all of the contributors in small or large ways and they are each kind people--if they hear from a wide swath of the community something you want, it will surely get considered, as everyone I've met likes to serve the community.

Issac is involved with both the Node Advisory Board and Node Forward. Bert Belder, also at StrongLoop, is also involved with these groups as well, and works with Issac. This post gives a good insight into what's happening with Node and io.js, which is sometimes bewildering to outsiders, particularly if you pay attention enough to see core contributors switching to io.js with seemingly no explanation.

And, according to Issac, the technical divergence between the projects might not be as extreme as some people make out:

Having witnessed some of the early discussions between the io.js technical committee and the Joyent contributors, there are only a small number of points of disagreement on both governance (stuff like how voting would happen if needed) and technical decisions (stuff like which version of v8 to use in the next release.)

He ends saying that he's confident that we'll end up with a single Node project. I don't personally have a problem with forks existing, but it would make my life easier if I only had to write about one "Node".

JSON Object to JSON Schema

Nijiko Yonskai, who has sent in several small but perfectly well-formed Node modules, has recently published JSON Object to JSON Schema (GitHub: Nijikokun/generate-schema, License: MIT, npm: generate-schema). This project helps you to convert JSON objects to schemas:

var GenerateSchema = require('generate-schema')

console.log(GenerateSchema({  
  "_links": {
    "self": {
      "href": "/gists/42"
    },
    "star": {
      "href": "/gists/42/star"
    }
  },
  "id": "42",
  "created_at": "2014-04-14T02:15:15Z",
  "description": "Description of Gist",
  "content": "String contents"
}));

This outputs an object with the types based on the content, so in this case it's mostly { "type": "string" }. I've recently been creating JSON schemas from existing JSON data sets, so this would have made my job easier!

conveyor-belt

Svilen Gospodinov sent in conveyor-belt (GitHub: svileng/conveyor-belt, License: MIT, npm: conveyor-belt). It's designed to switch client-side assets based on the current environment, so you can easily load development mode client-side scripts with lots of logging.

It looks like it'll work well with Connect/Express-based applications, but you could use it with other frameworks as well.

Featured

HTML testing forms node modules middleware sessions connect

Node Roundup: 0.11.3, Busboy, connect-mongostore, Chance

Posted on .

You can send in your Node projects for review through our contact form.

Node 0.11.3

Node 0.11.3 was released last week, which was a fairly large update: libuv, c-ares, and v8 were all updated. The debugger now breaks on uncaught exceptions, and there were changes to enable dtrace for libuv's probes (if enabled). The underlying implementation for buffers has undergone major changes as well -- I've picked out a few commits here that discuss the updates:

It looks like these changes should make the buffer implementation more robust. I've checked out Node 0.11.x and 0.10.x on my local machine and run make bench-buffer against both, so far 0.11 doesn't look conclusively faster, but I haven't been particularly scientific about the process yet.

Busboy

Busboy (GitHub: mscdex / busboy, License: MIT, npm: busboy) by Brian White is a streaming HTML form data parser. It uses the Dicer module to parse multipart fields, and also uses a stream parser for urlencoded fields.

The busboy API allows limits to be placed on the incoming data. The Busboy constructor accepts an options object which may include a limits property. Limits can include fieldNameSize, fieldSize, files, and more -- see the readme for full documentation. These options mostly default to Infinity, apart from fieldNameSize which is 100 bytes.

Tests are included, and it should be possible to use it as Express middleware fairly easily.

connect-mongostore

How do you decide which session middleware to use? Use cookies during early development then quickly search npm for something that uses your database? Me too! But there are better options out there and it's worth taking a bit of time to research them. Ilya Shaisultanov sent in connect-mongostore (GitHub: diversario / connect-mongostore, License: MIT) which is an attempt to write a cleaner session store that takes advantages of features like replica sets, and has test coverage.

Chance

Chance

Chance (GitHub: victorquinn / chancejs, License: MIT, npm: chance) by Victor Quinn is a library for generating random stings, numbers, and even things that are useful for test data like address elements and names.

It works in browsers and Node, and has a simple constructor-based API:

var Chance = require('chance');  
var chance = new Chance();  
chance.name({ middle: true });  

Featured

node modules express connect grunt cluster

Node Roundup: Node 0.10.12, grunt-micro, connect-prerenderer

Posted on .

You can send in your Node projects for review through our contact form.

Node 0.10.12

Node 0.10.12 was released yesterday. This version updates v8 and npm, and has a fix for the net module.

One minor change that I liked was readline now supports CTRL-L for clearing the screen -- that means Node's command-line interface will do this as well. Before hitting CTRL-L did nothing, which wasn't very intuitive if you're used to using readline tools.

grunt-micro

If size is important to you, then you'll like grunt-micro (GitHub: markdalgleish / grunt-micro, License: MIT, npm: grunt-micro) by Mark Dalgleish. This Grunt plugin ensures a script is smaller than a given size. Mark suggests this is useful for client-side authors that have size claims in their project documentation, but it could be useful for other things, like warning about asset sizes in mobile projects.

connect-prerenderer

connect-prerenderer (GitHub: dai-shi / connect-prerenderer, License: BSD, npm: connect-prerenderer) by Daishi Kato is middleware for pre-rendering content to support systems that don't interact well with Ajax-heavy interfaces. This is ideal for improving the SEO of a site.

The author has paid special attention to AngularJS -- the documentation includes some Angular client-side code that adds support for the module.

Featured

node modules express network security connect cluster

Node Roundup: evilscan, pm2, connectr

Posted on .

You can send in your Node projects for review through our contact form.

evilscan

It's finally here, TCP port scanning in Node! evilscan (GitHub: eviltik / evilscan, License: GPLv3, npm: evilscan) by Michel Soisson is a command-line tool, and has several interesting features, like control over the amount of concurrency, geolocation information, banner grabbing, and JSON output.

The author is focusing on connect scans, but is interested in adding SYN scans and UDP support. He's looking for contributors, and the project includes tests written with Mocha and Chai, so you really have no excuse not to help out! I think it's great to see well-tested security-related modules.

pm2

pm2

pm2 (GitHub: Unitech / pm2, License: MIT, npm: pm2) by Alexandre Strzelewicz is a command-line process manager for Node. It can be used to start a program as a cluster of processes, and then monitor the cluster's health, monitor the server itself (CPU/RAM/etc.), keep processes alive, log exceptions, and throttle programs that stop too quickly.

It also has tests written with Mocha, documentation, and examples.

connectr

connectr (GitHub: olalonde / connectr, License: MIT, npm: connectr) by Olivier Lalonde is a wrapper for Connect that allows middleware to be inserted at arbitrary points in the stack. That means you can add middleware before existing middleware.

It has a simple API: the before and after methods insert new middleware relative to other middleware, and it's also possible to add middleware to the top of the stack with first, or even based on an index.

Featured

node apps modules middleware connect

Node Roundup: 0.6.13, 0.7.6, ShareJS, Route66

Posted on .

You can send in your Node projects for review through our contact form or @dailyjs.

Node 0.6.13 and 0.7.6

Node 0.6.13 (stable) and 0.7.6 (unstable) have been released. These releases also update npm, and I noticed npm can now take OS and CPU properties in package.json. This is documented in the man page, so to read more type man npm-json or view the online version here: npmjs.org/doc/json.html.

Architectures and operating systems can even be blacklisted, so if you're sure your module runs fine everywhere except Windows, then this can be represented with "os" : [ "!win32" ].

ShareJS

ShareJS (GitHub: josephg / ShareJS, License: MIT, npm: share) by Joseph Gentle is an application that can be used to add concurrent editing to any web application. The server is Node, and the client is expected to use Ace for editing.

The author has already put together a ShareJS wiki with extra documentation (although the readme is pretty good too). Also of note is the decision to use Operational Transformations:

Most wikis have a 'save' button and do locking. OT is a class of algorithms that do multi-site realtime concurrency. OT is like realtime git. It works with any amount of lag (from zero to an extended holiday). It lets users make live, concurrent edits with low bandwidth.

According to the project's documentation, Joseph is an ex-Google Wave engineer (his LinkedIn profile mentions "Engineering Intern at Google"). Also, ShareJS has a 1:1 code to test LoC ratio.

Route66

Route66 (GitHub: vdemedes / route66, License: MIT, npm: route66) by Vadim Demedes is a middleware for routing in Connect 2.0. Vadim missed the connect.router middleware that was removed from Connect, so he created a replacement.

The decision behind removing the router was discussed at length in the Remove router ticket in Connect's GitHub issues.