-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (25 loc) · 987 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
var express = require('express'), // Express framework
mongoose = require('mongoose'), // MongoDB Mapping
bodyParser = require('body-parser'), // Request body parsing
config = require('./config'), // Config options
app = express() // Creating the express app
// Creating MongoDB Conntection
mongoose.connect(config.database.mongo_uri)
// Conditional module loading if in development
if ('development' == app.get('env')) {
app.use(require('errorhandler')())
}
// Express app config options
app.use(bodyParser.json())
app.set('port', config.server.port)
// Set as public root directory for static content
app.use("/public", express.static(__dirname + '/public'));
// Requiring RESTful user routes
require('./routes')(app)
// Starting server
app.listen(config.server.port, function() {
var status = 'Express server listening on port ' +
app.get('port') + ' in ' +
app.get('env') + ' mode.'
console.log(status)
})