An almost-web-framework. Use more Nginx!

Crazy Train isn’t a static file server and should always be reverse-proxied. Here’s an Nginx configuration snippet to serve up your static files:

location = / {
location / {
    root /path/to/your/project/public;
    try_files $uri $uri/ @proxy;
location @proxy {

This is always going to be more efficient and reliable than serving your static files using Node, so get used to developing with it, because you can change things without reloads, too.

If setting up a development Nginx given the above takes you more than about three minutes, you may be using the wrong operating system. Or are possibly not the fastest typist in the world.

Create a reasonable directory structure for your project. This is the one I use:

$ mkdir project/{,public/{,stylesheets,scripts,images,fonts},templates}

Then you’ll set up some initial dependencies. May I recommend:

$ cd project
$ ed
    "dependencies": {
        "pg": "~2.8.2",
        "crazy": "0.1.0",
        "razorleaf": "~1.6.0"
wq package.json
$ npm install

Now you can write your server!

$ ed
"use strict";
var fs = require("fs");
var pg = require("pg");
var path = require("path");
var crazy = require("crazy");
var razorleaf = require("razorleaf");
function readTemplate(name) {
    var filename = path.join(__dirname, "templates", name + ".leaf");
    return fs.readFileSync(filename, "utf8");
function loadTemplate(name) {
    return razorleaf.compile(readTemplate(name), { include: readTemplate });
var app = new crazy.Application();
var templates = {
    home: loadTemplate("home")
app.get("/", function(request, response, url) {
    response.writeHead(200, { "Content-Type": "text/html;charset=utf-8" });
app.listen(8000, "");
w server.js
        meta charset: "utf-8"
        title "Hello, world!"
        h1 "It works!"
w templates/home.leaf
$ node server

Yes, this is a little verbose for now, but wait while Crazy Train gets started! In the meantime, it’s a good idea to read the documentation for the libraries used here. Know what every part does at all times!