Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
2
Indexable
Never
const express = require('express');
const colors = require('colors');
const path = require('path');
const app = express(); 
const mysql = require('mysql');
const UserService = require('./DBconnection/UserService');
const dbConnection = mysql.createConnection({
    host:"localhost",
    user:"root",
    password:'berna',
    database:'holuagos'
})


const userService = new UserService(dbConnection);

userService.dbConnection = dbConnection;

const newUser = { name: 'John Doe', email: 'john@example.com' };
const id = '6'
//userService.deleteUser(id);
//userService.createUser(newUser);
const tableUser = userService.selectAll();

app.get('/about',(req,res)=>{
    res.status(200).render('about.html',{title:'Sobre Nosotros',tableUser: tableUser})
})

//userService.setDbConnection(dbConnection);
 
//settings
app.set('port',3000);
app.set('views',path.join(__dirname,'views'));
app.engine('html', require('ejs').renderFile);
app.set('view engine','ejs');
//middlewares

//routes
app.use(require('./routes/index'));
//static files
app.use(express.static(path.join(__dirname,'public')));
//listening server
app.listen(app.get('port'),()=>{
    console.log('Server on port'.green ,app.get('port'));//En que puerto esta escuchando el server
    
});