-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
56 lines (43 loc) · 1.42 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
var express = require('express');
var app = express();
var morgan = require('morgan');
var port = process.env.PORT || 3000;
var mongoose = require('mongoose');
var methodOverride = require('method-override');
var bodyParser = require('body-parser');
var cors = require('cors');
var routes = require('./config/routes');
var upload = require('jquery-file-upload-middleware');
mongoose.connect( process.env.MONGODB_URI || 'mongodb://localhost:27017/lineup_groupdevelopment');
app.get("/" , function(req, res){
res.sendFile(__dirname + "/public/homepage.html");
});
app.use(express.static('public'));
// MIDDLEWARE
app.use(cors());
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(methodOverride(function(req, res){
if (req.body && typeof req.body === "object" && "_method" in req.body){
var method = req.body._method;
delete req.body._method;
return method;
}
}));
app.use(routes);
// configure upload middleware for file upload
upload.configure({
uploadDir: __dirname + '/public/uploads',
uploadUrl: 'public/uploads',
imageVersions: {
thumbnail: {
width: 80,
height: 80
}
}
});
app.use('public/upload', upload.fileHandler());
app.listen(port, function() {
console.log("Express is listening on port " + port);
});