-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
79 lines (62 loc) · 1.95 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var express = require("express"),
http = require("http"),
stylus = require("stylus"),
swig = require("swig"),
assetify = require("assetify").instance(),
nib = require("nib"),
conf = require("./conf"),
log = conf.log;
var app = express();
app.configure(function() {
app.set("views", __dirname + "/views");
app.engine("html", swig.renderFile);
app.set("view engine", "html");
// TODO: Explain this shit
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.methodOverride());
// TODO: Clean this up
app.locals = {
app: {
dev: conf.dev
},
wat: "Test string from node.js"
};
// TODO: Document
app.use(app.router);
// TODO: Document
// Use stylus middleware if we are not using assetify
if (conf.dev) {
app.use(stylus.middleware({
src: __dirname + "/public/styl",
dest: __dirname + "/public/css/",
compile: function(str, path) {
return stylus(str)
.set("filename", path)
.set("compress", true)
.use(nib())
.import("nib");
}
}));
}
// Enable middleware and expose 'assetify' to template
// TODO: Don't serve bundled assets in development. Makes things easier to debug
// Assets must be built with 'jake build' change this?
assetify(app, express, conf.assetify.assets.bin);
app.use(express.static(__dirname + "/public"));
});
app.get("/", function(req, res) {
res.send("Hello World! Deploying from Jake!");
});
app.get("/swig", function(req, res) {
res.render("index", {
title: "Index!"
});
});
var server = http.createServer(app);
exports.listen = function(port, callback) {
server.listen(port, callback);
};
exports.close = function(callback) {
server.close(callback);
};