-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
46 lines (36 loc) · 1.04 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
/*!
* Nodejs.bg
*
* Node.js Bulgarian User Group
* Copyright (c) 2011 Veselin Todorov <[email protected]> & Martin Lazarov <[email protected]>
* Licensed under the MIT License.
*/
/**
* Module dependencies.
*/
var express = require('express');
var app = module.exports = express.createServer();
var UriBuilder = require('./lib/uri_builder');
var mongoose = require('mongoose');
// Configurations.
var config = app.config = require('./config/config');
// Database configurations.
var db = require('./config/db');
// Bootstrap and setup.
require('./config/boot.js')(app, express);
// Database connection.
mongoose.connect((new UriBuilder(db[app.settings.env])).toString(),function (err){
if(err){
throw err;
}
});
// Helpers.
require('./helpers/helpers.js')(app);
// Dynamic Helpers.
require('./helpers/dynamic_helpers.js')(app);
// Resources.
require('./resources')(app);
// Starting the server.
app.listen(config.server.port, function() {
console.log('nodejs.bg listening on port %d in %s mode', app.address().port, app.settings.env);
});