forked from devjseu/ExtExpressNodeMongoDbApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·41 lines (34 loc) · 967 Bytes
/
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
/**
* Module dependencies.
* @author lukasz.sudol <lukasz@devjs.eu>
*/
var express = require('express');
var router = require('./application/router');
var http = require('http');
var path = require('path');
var dbPath = 'mongodb://localhost/devjs';
// import the data layer
var mongoose = require('mongoose');
// import the models
var models = {
User: require('./application/model/user')(mongoose)
};
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
//db connection
mongoose.connect(dbPath, function onMongooseError(err) {
if (err) throw err;
});
//router
router.init(app, models);
app.listen(8080);
console.log('Listening on port 8080');