Skip to content

Instantly share code, notes, and snippets.

@tuliofaria
Last active November 16, 2018 20:09
Show Gist options
  • Save tuliofaria/5b15d8fdd6f32d16bb1814062732cbb3 to your computer and use it in GitHub Desktop.
Save tuliofaria/5b15d8fdd6f32d16bb1814062732cbb3 to your computer and use it in GitHub Desktop.
const express = require('express')
const path = require('path')
const app = express()
const port = process.env.PORT || 3000
const mysql = require('mysql')
const connection = mysql.createConnection({
host:'127.0.0.1',
port:'8889',
user:'root',
password:'root',
database:'cadastro'
})
const dependencies = {
connection
}
const pessoas = require('./routes/pessoas')
app.use(express.static('public'))
app.get('/',(req,res) => res.render('home'))
app.use('/pessoas',pessoas(dependencies))
//Diretório em que será guardado os view engines
app.set('views',path.join(__dirname,'views'))
app.set('view engine','ejs')
connection.connect((err) => {
console.log(err)
app.listen(port, () => console.log('CRUD listening on port: '+port))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment