Node Modules Used by Ghost

Ghost is the first major open source product written to run on NodeJS (anyone disagree?). If you haven't heard already, Ghost is a blogging tool that strips away the complexities of WordPress. It has the backing of two developers that were heavily involved with WordPress. Ghost started out with a killer KickStarter campaign. Let's take a peek behind the covers and look at the Node modules currently in use by Ghost.

If you are familiar with Git then you can pull the code from Github with the following command.

git clone https://github.com/TryGhost/Ghost.git

If you aren't familiar with Git then you can peruse the code on the Github website. By viewing the package.json file you can get a nice list of the node modules used by Ghost.

// snippet from package.json.
"dependencies": {
    "express": "3.4.2",
    "express-hbs": "0.3.0",
    "connect-slashes": "0.0.10",
    "node-polyglot": "0.2.1",
    "moment": "2.1.0",
    "underscore": "1.5.1",
    "showdown": "0.3.1",
    "sqlite3": "2.1.16",
    "bookshelf": "0.5.7",
    "knex": "0.4.11",
    "when": "2.2.1",
    "bcrypt-nodejs": "0.0.3",
    "node-uuid": "1.4.0",
    "colors": "0.6.1",
    "semver": "2.1.0",
    "fs-extra": "0.6.3",
    "downsize": "0.0.2",
    "validator": "1.4.0",
    "rss": "0.2.0",
    "nodemailer": "0.5.2"
},

Express

Ghost sits on the most popular web application framework for NodeJS, Express. Interestingly they went with Handlebars as the page templating tool instead of Jade or EJS.

Connect Slashes

The connect-slashes package will append or remove a trailing slash to all request urls. So GET requests will be redirected if the url doesn't conform to your site's standard url format. This is a very simple and powerful tool.

Node Polyglot

The node-polyglot package helps with globalization in JavaScript.

Moment

The moment package is used for parsing, validating, manipulating, and formatting dates with multiple language support. It has "TimeAgo" support which I like to use in my web UIs.

moment().endOf('day').fromNow();
// returns something like...
>> in 4 hours

Showdown

The Showdown package is how Ghost handles Markdown to HTML conversion. An example usage is shown below.

var Showdown = require('showdown');
var converter = new Showdown.converter();

converter.makeHtml('#hello markdown!');

Bookshelf

The data access in Ghost is handled by the Bookshelf package. The Bookshelf ORM supports postgreSQL, mySQL, and SQLite3.

When

The when package is an implementation of async/promises for JavaScript.

Node UUID

JavaScript doesn't native functionality to generate universally unique ids (UUIDs). Microsoft's implementation of UUIDs is commonally referred to as globally uniqie identifiers (GUIDs). The node-uuid package can generate v1 and v4 UUIDs from the RFC4122 spec.

Downsize

The downsize package can do word truncation, character truncation, or append ellipsis for markup. It's best explained via an example.

downsize("<p>some markup here...</p>",{"characters": 6, "append": "..."});

<p>some m...</p>

Rss

The rss package can be used to easily add an RSS feed to any node application.

Ghost leverages many existing Node packages. Here we covered most of the packages.