forked from map1t0/mapito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (28 loc) · 908 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
var http = require('http');
var express = require('express');
var fs = require("fs");
var mongoose = require('mongoose');
var passport = require('passport');
var dbconfig = require('./config').db;
var app = express();
mongoose.connect(dbconfig.url());
var db = mongoose.connection;
db.on('error', console.error);
db.once('open', function() {
console.log('Mongodb: Success connect!');
});
require('./config/passport')(passport);
require('./config/express')(app, passport);
fs.readdirSync(__dirname + "/models").forEach(function(filename) {
if(filename.indexOf(".js")) {
require(__dirname + "/models/" + filename);
}
});
fs.readdirSync(__dirname + "/routes").forEach(function(filename) {
if(filename.indexOf(".js")) {
require(__dirname + "/routes/" + filename)(app, passport);
}
});
http.createServer(app).listen(app.get("port"), function(err) {
console.log("Nodejs: Server started!");
});