//routes
module.exports = function(app){
app.get('/', function(req, res){
var connection = app.infra.connectionFactory();
var produtosDAO = new app.infra.ProdutosDAO(connection);
produtosDAO.lista(function(erros, result){
res.render('home/index', {livros: result});
//console.log(result);
});
connection.end();
});
};
//config do express
var express = require('express');
var load = require('express-load');
var bodyParser = require('body-parser');
var expressValidator = require('express-validator');
module.exports = function(){
var app = express();
app.use(express.static('./app/public'));
app.set('view engine','ejs');
app.set('views','./app/views');
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(expressValidator());
load('routes',{cwd:'app'})
.then('infra')
.into(app);
return app;
};