Edit in JSFiddle

var express = require('express');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var path = require('path');

var mongoose = require('mongoose');
var config = require('dotenv').config();
mongoose.Promise = Promise;
mongoose.connect('mongodb://localhost/'+process.env.DB_NAME);
var db = mongoose.connection;


const Company = require("./models/Company.js");
const User = require("./models/User.js");
const Event = require("./models/Event.js");
const Proposal = require("./models/Proposal.js");


var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());

app.use('/api/proposal', require('./routes/proposals'));
app.use('/api/event', require('./routes/events'));
app.use('/api/user', require('./routes/users'));
app.use('/api/events', require('./routes/events'));
app.use('/api/chats', require('./routes/chats'));
app.use('/api/companies', require('./routes/companies'));
app.use('/api/misc', require('./routes/misc'));

app.use('/uploads',function(req,res,next){
	console.log("uploads ",req.url);
	next();
})
app.use('/uploads',express.static(path.join(__dirname, 'uploads')));

// catch 404 and forward to error handler
app.use(function(req, res, next) {
	var err = new Error('Not Found');
	err.status = 404;
	next(err);
});

// error handler
app.use(function(err, req, res, next) {
	// set locals, only providing error in development
	console.log("error ",err);
	res.locals.message = err.message;
	res.locals.error = req.app.get('env') === 'development' ? err : {};

	// render the error page
	res.status(err.status || 500);
	res.render('error');
});

process.on('uncaughtException', function(err) {
	console.log('Caught exception: ', err);
	console.log(err);
	console.log('Exception data : ' + JSON.stringify(err, ["message", "arguments", "type", "name"]) );
});

db.on('error', () =>{
	console.log('Error ');
});
db.once('open', function() {
	app.listen(process.env.PORT, function () {
		console.log("Planport running on port ",process.env.PORT);
	});
});