die

Application and asset management to die for.

npm install die
57 downloads in the last week
114 downloads in the last month

Introduction

Die is a framework for building reusable JavaScript applications. It can be used to build anything from a single-page application to a full stack web application framework. Die does it's best to stay out of your way, allowing you the utmost in control over your application.

Use the defaults or just what you need and build whatever you want.

Features

Razor-sharp DSL for Express

Die supports a Zappa-ish DSL for Express making the already fast process of building Node.js server applications with Express even faster!

app = require('die')({
    base: __dirname
});

app.extend(function(){
    this.get('/', function(){
        this.render('index');
    });
});

Or even more succintly with CoffeeScript:

app = require('die')
    base: __dirname

app.extend ->
  @get '/', -> @render 'index'

Share code between client and server

JavaScript is an isomorphic language, which means it can execute on both the client and server. Die lets you leverage this by allowing you to organize your code into Node.js compatible modules.

var HomeView = Backbone.View.extend({
  // Require another module (a compiled template) in to your Backbone view.
  template: require('./templates/home'),
  render: function() {
    $(this.el).html(this.template())
    return this;
  }
}

// Export your view so that it can be used from other modules.
module.exports = HomeView

Die uses Requisite to package up your client code, resolving dependencies, and bundling everything together for you automatically.

Stylus with nib and Bootstrap baked in

Modernize your CSS with Stylus! Bootstrap and nib baked in:

// everything
@import 'bootstrap'

// only config and forms
@import 'bootstrap/config'
@import 'bootstrap/forms'

h1
  font-size 20px

Awesome testing with Mocha

Mocha has emerged as a best-in-class JavaScript testing framework, and Die supports it out of the box.

Multi-app support

By default each app created by Die is reusable by other Die/Express apps. Example configuration:

// Add app2's static paths to the stack, make client-side code available.
app.inject(app2);

// Mount app3 in it's entirety at /app3
app.mount('/app3', app3);

Each app can of course require other apps recursively.

Project Templates

Never write boilerplate code again, take advantage of Die's project templates. Structure your projects however you like, each file in a template folder will be treated as a Mustache template and can be passed any sort of arbitrary variables when creating a new project with die new. Check out the default templates for examples.

Usage

Create new project based off template:

die new <name> [--template <template name>, --install, --production]

Serve project (or just static files):

die run

Compile client-side assets:

die build

Can also be used to build stand-alone CSS and JavaScript assets:

die build --minify --css [in] --css-path [out] --js [in] --js-path [out]

Compile & watch client-side assets, recompiling on change:

die watch

Run tests:

die test

Development

Before you can hack on die you need to:

  • Clone your forks of Requisite and die in the same parent folder

  • Set up Requisite

    • cd requisite/; npm install && cake build
  • Set up die

    • cd../die/; git branch develop; git co develop
    • npm install && npm link ../requisite && cake build
npm loves you