steeplejack

3.2.0 • Public • Published

Steeplejack

Gitter NPM Version NPM Downloads Node.js Version Build Status Code Quality Dependencies Dev Depedencies

An easy way of making a Twelve Factor App in NodeJS

What is Steeplejack?

The goal of this project is to write reusable applications, using reusable components in whatever flavour of JavaScript you want.

When creating a new project, you need to set up the same things over and over again - your data models and collections, your dependency injection, your HTTP server, your routing and your logging. With Steeplejack, this is all there by default allowing you to get straight into your coding.

This is not a framework, it is scaffolding for modules. It doesn't tell you how to write your software, it just lets you do it. You can use Express or Restify as your HTTP strategy or even one of your own. So long as it satisfies the strategy, it doesn't care.

Almost every application will require some form of data storage. It's likely there will be some form of user management too. In the most part, these will be the same across all your projects. So, write these as plugins and use them across multiple projects rather than write it afresh each time.

What makes the Twelve Factor App so great?

Pick any of the following reasons:

  • makes your software more robust
  • makes your software truly scalable
  • you can give true long-term support for your software
  • happier developers

Steeplejack adds to this by:

  • allowing you to reuse your code in the form of plugins
  • being stupidly easy to set up a new server
  • things needed in every piece of software - error logging, data modelling and routing - are provided out-of-the-box

Config

A litmus test for whether an app has all config correctly factored out of the code is whether the codebase could be made open source at any moment, without compromising any credentials.

Twelve Factor App: Config

A lot of developers still specify all the different config environments in their config file. That was great when we wrote PHP and there were only three instances; dev, test and live. The power of NodeJS comes from it's scalability - how scalable is it going to be if, every time the operations guy wants to add a new server at 2am, you need to get out of bed and add in a new environment in your config file?

Get rid of all the environments out of your config file and just have one (the development one, so you don't have to dig around each time you download from the repo). For all other deployments of your software, use environment variables. Then it's the deployer's responsibility to put in the right config and you can stay in bed.

Steeplejack offers a single config file that can be overwritten by either environment variables or command line arguments. The application then has one single source of truth with your config and it's your choice how to specify the deployment config.

Data Modelling

The Twelve Factor App is all about loose coupling to your attached resources. You might start by using MongoDB, but there will be a time when that isn't the best solution. If you're using something like Mongoose, you are tied-in to MongoDB regardless.

The data modelling in Steeplejack is all about the data - it doesn't care where you store it, if indeed anywhere. The data is designed to be used by your application and stored in a way you decide. If your model doesn't match your data store exactly, no problem. There is a loose link between the model and the storage.

When you're dealing with lots of models, you can create a collection. Maybe you get your data from multiple sources and want to sort it in the application. Steeplejack allows you to write a simple method to do that.

Why's it called 'Steeplejack'?

When I started thinking about a scaffolding project, I was watching a Fred Dibnah documentary. Fred was a great enthusiast of beautiful engineering. It struck me as a great metaphor for what I was trying to achieve. By trade, Fred was a steeplejack, so the name is a little nod to him.

Fred Dibnah

License

MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i steeplejack

Weekly Downloads

4

Version

3.2.0

License

MIT

Last publish

Collaborators

  • npm