Desplegando App
This commit is contained in:
53
src/app.js
Normal file
53
src/app.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const morgan = require('morgan');
|
||||
const mysql = require('mysql');
|
||||
const myConecction = require('express-myconnection');
|
||||
var puerto = 3001
|
||||
|
||||
const app = express();
|
||||
//importando rutas
|
||||
const clientesRutas = require('./rutas/rt_clientes');
|
||||
const productosRutas = require('./rutas/rt_items');
|
||||
const generalesRutas = require('./rutas/rt_Generales');
|
||||
|
||||
//configuraciones
|
||||
app.set('port',process.env.PORT||puerto);
|
||||
app.set('view engine','ejs');
|
||||
app.set('views',path.join(__dirname, 'views'));
|
||||
//app.set('vistas',path.join(__dirname, 'vistas'));
|
||||
|
||||
//middlewares
|
||||
app.use(morgan('dev'));
|
||||
app.use(myConecction(mysql,{
|
||||
//host:'192.168.10.50',
|
||||
host:'172.17.0.2',
|
||||
user:'admin',
|
||||
password:'Dx.1706%',
|
||||
port:3306,
|
||||
database:'TELCOTRONICS'
|
||||
},'single'));
|
||||
//cuando reciba dato desde req body
|
||||
app.use(express.json({limit: '25mb'}));
|
||||
app.use(express.urlencoded({limit:'25mb',extended:false}));
|
||||
|
||||
//rutas
|
||||
app.use('/', clientesRutas);
|
||||
app.use('/', productosRutas);
|
||||
app.use('/', generalesRutas);
|
||||
|
||||
//prueba de json directa
|
||||
app.get('/pruebaJson',function(req,res){
|
||||
res.json([
|
||||
{nombre:"Tarea1",detalle:"programacion"},
|
||||
{nombre:"Tarea2",detalle:"Android Json"}
|
||||
]);
|
||||
});
|
||||
|
||||
//archivos staticos
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
//inicia servidor
|
||||
app.listen(app.get('port'),() =>{
|
||||
console.log('Servidor activo App SIGMA Puerto: '+puerto);
|
||||
});
|
||||
Reference in New Issue
Block a user