-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
57 lines (44 loc) · 2.2 KB
/
app.js
File metadata and controls
57 lines (44 loc) · 2.2 KB
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
/**
* Module dependencies.
*/
var express = require('express'),
http = require('http'),
path = require('path');
// add some sugar baby
require('sugar');
var app = module.exports = express();
app.configure(function(){
app.set('port', process.env.PORT);
app.set('mongo', process.env.MONGOLAB_URI);
app.set('cloudinary', process.env.CLOUDINARY_URL);
app.set('sendgrid', { user: process.env.SENDGRID_USERNAME, key: process.env.SENDGRID_PASSWORD });
app.set('admin', { username: 'admin', password: process.env.ADMIN_PASSWORD});
app.set('site', 'Mouse');
app.engine('html', require('consolidate').dust);
app.set('view engine', 'html');
app.set('views', path.join(__dirname, 'views'));
app.use(express.compress());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('magical secret ronin'));
app.use(express.cookieSession({cookie: { maxAge: (20).minutes() }}));
app.use(express.static(path.join(__dirname, 'public')));
require('formage-admin').init(app, express, require('./models'), {
title: app.get('site')
});
app.use(app.router);
app.use(function(req, res, next){
res.status(404);
res.render('404', {title: 'The page cannot be found', content: '<p>The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.</p><hr><p>Please try the following:</p><ul><li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.</li><li>If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted.</li><li>Click the <a href="javascript:history.back(1)">Back</a> button to try another link.</li></ul><h2>HTTP Error 404 - File or directory not found.</h2><hr>'});
})
});
app.configure('development', function(){
app.use(express.logger('dev'));
app.use(express.errorHandler());
});
require('./dust/helpers');
require('mongoose').connect(app.get('mongo'));
require('./routes')(app);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});