forked from brendannee/ziftbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
73 lines (62 loc) · 2.27 KB
/
config.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
var express = require('express')
, expressNamespace = require('express-namespace')
, mongoose = require('mongoose')
, stylus = require('stylus')
, nib = require('nib')
, jadevu = require('jadevu')
, Zappos = require('zappos');
try {
var keys = require('./keys');
} catch(e) {
console.log(e);
}
require('./models/question');
module.exports = function(app) {
app.configure('development', function(){
this
.use(express.logger('\x1b[90m:remote-addr -\x1b[0m \x1b[33m:method\x1b[0m' +
'\x1b[32m:url\x1b[0m :status \x1b[90m:response-time ms\x1b[0m'))
.use(express.errorHandler({dumpExceptions: true, showStack: true}))
.enable('dev')
.set('domain', 'test.ziftbot.com');
});
app.configure('production', function(){
this
.use(express.logger({buffer: 10000}))
.use(express.errorHandler())
.enable('prod')
.set('domain', 'ziftbot.com');
});
app.configure(function() {
var zapposKey = process.env.ZAPPOS_KEY || keys.zappos;
app.set('zappos', new Zappos(zapposKey));
var mongoPass = process.env.MONGO_PW || keys.mongoPass;
var mongoUser = process.env.MONGO_USER || keys.mongoUser;
var mongoDB = process.env.MONGO_DB || keys.mongoDB;
console.log('mongopass:' + mongoPass + ' mongoPass:' + ' mongoUser:' + mongoUser + 'MongoDB:' + mongoDB);
var db = mongoose.connect('mongodb://'+ mongoUser +':' + mongoPass + '@' + mongoDB);
app.set('db', db);
var sendgridPass = process.env.SENDGRID_PW || keys.sendgrid;
app.set('sendgrid', { username: 'blinktag', password: sendgridPass });
this.use(express.cookieParser())
.use(express.bodyParser())
.set('views', __dirname + '/views')
.set('view engine', 'jade')
.set('public', __dirname + '/public')
.enable('error templates')
.use(express.static(this.set('public')))
.use('/css', stylus.middleware({
force: true
, compress: true
, debug: true
, src: __dirname + '/styles'
, dest: this.set('public') + '/css'
, compile: function(str, path) {
return stylus(str)
.set('filename', path)
.set('paths', ['/style'])
.use(nib());
}
}))
});
}