/**
 * Module dependencies
*/
var express  = require('express');
var mongoose = require('mongoose');
var passport = require('passport');
var flash    = require('connect-flash');
var http = require('http');
var path = path = require('path');
var uuid = require('node-uuid');


var vhost = 'acomanda.local'
var port     = process.env.PORT || 3000;
var ip     = process.env.IP || "localhost";

var app = express();

if (app.get('env') === 'development') {
    var uri_local = require('../database_local'); // not used, usage config/database.js
    process.env.MONGOLAB_URI = uri_local;
};

var connection = require('./config/database')(mongoose);
var models = require('./models/models')(connection);
require('./config/passport')(passport,models); // pass passport for configuration



app.configure(function() {
    // set up our express application
    app.set('port', port);
    app.use(express.logger('dev')); // log every request to the console
    app.use(express.cookieParser()); // read cookies (needed for auth)
    app.use(express.bodyParser()); // get information from html forms
    app.set('view engine', 'html'); // set up html for templating
    app.engine('.html', require('ejs').__express);
    app.set('views', __dirname + '/views');
    app.use(express.static(path.join(__dirname, 'public')));
    //app.use(express.session({ secret: 'keyboard cat' }));// persistent login sessions
    app.use(express.methodOverride());
    app.use(express.json());
    app.use(express.urlencoded());
    //app.use(flash()); // use connect-flash for flash messages stored in session

    //passport configuration
    app.use(passport.initialize());
    app.use(passport.session());// persistent login sessions
    //provagg
    app.use(app.router); //init routing

});

require('./app/routes.js')(app, passport,models); // load our routes and pass in our app and fully configured passport

// development only
if (app.get('env') === 'development') {
    app.use(express.errorHandler());
};

// production only
if (app.get('env') === 'production') {
    // TODO
};

//express.vhost(vhost, app);

var server = http.createServer(app).listen(app.get('port'), function () {
    console.log('Express server listening on port ' + vhost+":"+server.address().port);
});
@@ -267,17 +267,40 @@
 uuid');%0A
+var fs = require('fs');
 %0A
-
 %0Avar vho
@@ -465,24 +465,172 @@
 lopment') %7B%0A
+%0A    var file_local = '/home/tomazini/Projetos/NodeJs/config_local.js';%0A    if (fs.existsSync(file_local)) %7B%0A        console.log('found file');%0A    
     var uri_
@@ -649,27 +649,18 @@
 ire(
-'../databas
+fil
 e_local
-'
 ); /
@@ -696,16 +696,20 @@
 base.js%0A
+    
     proc
@@ -742,16 +742,74 @@
 _local;%0A
+    %7D else %7B%0A        console.log('not found file');%0A    %7D%0A
 %7D;%0A%0Avar 

add config local