-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
51 lines (43 loc) · 1.34 KB
/
server.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
var express = require('express'),
env = process.env.NODE_ENV || 'development',
logfmt = require('logfmt'),
less = require('less'),
lessMiddleware = require('less-middleware'),
path = require('path'),
config = require('./config')[env],
mongo = require('mongodb'),
http = require('http'),
monk = require('monk'),
mongoURI = process.env.MONGOLAB_URI ||
process.env.MONGOHQ_URL ||
'localhost:27017/jennyjtest',
routes = require('./routes'),
S3PATH = 'https://jennytest.s3.amazonaws.com'
var app = express();
//app.use(logfmt.requestLogger());z
var db = monk(mongoURI);
db_images = db.get('images');
var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
console.log("Listening on " + port);
});
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.logger('dev'))
app.use(express.static(__dirname + '/public'))
app.use(express.methodOverride());
//bodyParser must be before router.... thanks docs.
app.use(express.bodyParser())
app.use(app.router);
//app.use(form({ keepExtensions: true }));
app.use(express.static(__dirname + '/public'))
app.get('/', function(req, res) {
db_images.find({}, {sort: {'_id' : -1}}, function(e, docs) {
console.log(e);
console.log(docs);
res.render('index', {
images : docs
});
})
});
app.post('/balls', routes.balls);