The JavaScript blog.


node apps modules gbnc

Ghost: A Blogging Platform

Posted on .


Ghost (GitHub: TryGhost / Ghost, License: MIT) is a blogging platform built with Node and Express. It uses CasperJS for testing, and Bookshelf.js for the ORM layer.

Ghost started out as a Kickstarter project, with the aim of bettering WordPress. Ghost is run by a non-profit organisation, and released the source code today under the MIT license. Ghost is also run as a service, so you can create an account at ghost.org and try it out without having to install it.

However, fortunately it is pretty easy to install: npm install --production and npm start should get it running. It's easy because Bookshelf.js is database agnostic, so if your system has SQLite then it should be able to use it to store posts and users.

Event better, the fact Bookshelf.js is based around Backbone.js means you should be able to start hacking Ghost without much trouble. If you've done any work with Express and Backbone.js then Ghost's source will be eminently hackable.

The project is split into client and server code, and it uses popular patterns like promises, Express route separation, and Express middleware.

The architecture of the project has been shaped by the need to allow people to easily install and theme Ghost blogs, which means it deviates from the typical Express applications I write which are bespoke services. The focus on theming came from the need to create a similar designer-friendly ecosystem that WordPress has, and already on launch themes and services that sell themes are available. You can read more about this in Ghost Launches to The Public.

The fact the project started off as a Kickstarter project with hundreds of eager alpha testers means it already feels mature. And unlike many open source projects it has a dedicated team and a business model behind it, so it's definitely off to a promising start. I recommend giving it a look over if you're an Express developer or just tired of your own blogging platform.


node modules hardware gbnc

Espruino: JavaScript Hardware Hacking

Posted on .


Espruino is a cheap and tiny microcontroller that can be scripted with JavaScript. That means you can use JavaScript and an Arduino-inspired API to communicate with sensors, motors, and LCD displays. Rather than using Arduino's Processing-derived IDE, or Node modules to communicate with Arduino, you can use something designed with JavaScript in mind from the ground up.

There's an official Espruino board, but there are also compatible boards that you can use. The Espruino firmware can be installed on the other boards manually, so if you've already dabbled with microcontrollers you should be able to get a compatible board loaded up and ready to run. The Espruino hardware reference has more details.

The Raspberry Pi has some IO pins (the GPIO connector), but microcontroller-based boards like the Espruino use much less power. That means you could leave a board running on batteries for a significant amount of time.

The project was successfully funded on Kickstarter, where they raised £100,710.

If you want to flash a compatible microcontroller check out Espruino's downloads page. If you want to see the source, go to espruino / Espruino. It contains a JavaScript lexer and parser, because the author (Gordon Williams) found V8 and SpiderMonkey used too much RAM to run on the chips he wanted to target. Have a look at the C source code if you're interested in seeing how it works.


node modules npm gbnc

Beams: Streams with Computation

Posted on .

Beam (GitHub: darach / beam-js, License: MIT, npm: beam) by Darach Ennis is a module for performing computation on streamed data.

Beams are like streams, in that they support pipes but are lightweight and work with in memory types without buffering, copying, parsing.

Beams have some interesting properties:

  • Events are executed in order
  • Events can be filtered
  • Beams can be branched and joined together


I've taken one of Darach's basic examples and interleaved it with comments to explain the major concepts. The goal is to pipe numbers through an operator that can square numbers.

First, load the module and create a sink.

var Beam = require('beam');  
var sink = Beam.Sink();

sink.on('data', function(data) {  
  console.log('d:', data);

Sinks emit a 'data' event whenever data is received, so they can be used to capture results. Operators can be used to transform data -- this example just squares each value:

var square = Beam.Operator.transform(function(x) { return x * x; });  

Sources can be connected to sinks with pipe, much like streams:

var source = Beam.Source();  

Values can be sent to a source with push:

for (var i = 0; i <= 10; i++) {  

This example introduces sinks, sources, and operators, but it doesn't even scratch the surface of what Darach is aiming for with Beams. The next step is to define a filter and declare a pipe that uses it:

var even = Beam.Operator.filter(function(x) { return x % 2 == 0; });  

Now only even numbers will be squared. The Beams module also has built-in functions, which you can find in Beam.bifs. These are operators and filters that you can use to filter and compare values in beams:

var mod2 = source.pipe(b.mod(2))  

To see all of the defined Bifs, see _beam_bifs.js.


events node modules npm gbnc

Node Roundup: Great British Node Conference Edition

Posted on .

Yesterday was the Great British Node Conference, which took place in London at the Shoreditch Works Village Hall. Speakers included Julian Gruber, Darach Ennis, Anton Whalley, and Tim Ruffles.

I did a talk about Node's internals that went from the JavaScript core modules down to some libuv basics, with the aim of encouraging the audience to look at Node's source for themselves. I want to break this talk down into a deeper analysis of uv and V8 while still remaining relevant to JavaScript developers.


Substack did a short talk about abstract syntax trees, Browserify, and a project he's working on to remove unreachable code. He mentioned testling, which I haven't seen before -- it's another way to run headless browser tests. I was recently trying to rethink the way I do this, so I'm going to give it a try.

Milo Mordaunt and Harry Dalton did an interesting talk about some games they created based on British government data. One of the games used Max Ogden's voxel-engine project.

In the audience I talked to Sven Lito who is one of the creators of Hoodie. Hoodie is a noBackend project that aims to make web applications easier to build. It reminded me of Meteor, but my initial impression was that it's more closely reliant and influenced by the Node community, so I'd like to spend more time looking at it.

Over the next week or so I'll write a little bit more about the projects and technologies I learned about at the conference.