This repository has been archived by the owner on Jun 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
74 lines (60 loc) · 1.66 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
/**
* Module dependencies.
*/
var applicationRoot = __dirname,
express = require('express'),
router = require('./routes'),
http = require('http'),
path = require("path"),
bootstrap = require('bootstrap-stylus'),
stylus = require('stylus'),
nib = require('nib'),
hbs = require('hbs'),
mongoose = require('mongoose');
var app = express();
function compile(str, path) {
return stylus(str)
.set('filename', path)
.set('compress', true)
.use(nib());
}
/**
* Configuration
*/
app.configure(function()
{
app.use(express.favicon());
app.set('view engine', 'html');
app.engine('html', require('hbs').__express);
app.set('views', __dirname + '/views');
app.use(stylus.middleware({
src: applicationRoot + '/public',
compile: compile
}));
app.use(express.static(path.join(applicationRoot, 'public')));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.logger('dev'));
app.set('port', process.env.PORT || 8080);
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
mongoose.connect('mongodb://localhost/questience');
});
/* DB */
app.configure('staging', function() {
console.log('Configuring middleware for the production environment.');
app.use(express.static(__dirname + '/public'));
mongoose.connect('mongodb://heroku_app7204375:5bes70u23r9ucvje0m2frjhb89@ds037447-a.mongolab.com:37447/heroku_app7204375');
});
/**
* Routes
*/
router.setRoutes(app, mongoose);
/**
* Initialize server
*/
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});