-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
35 lines (27 loc) · 906 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const express = require('express');
const path = require('path');
const morgan = require('morgan');
const mysql = require('mysql');
const app = express();
const port = process.env.PORT || 8080;
const db = mysql.createConnection({
host: "cis9cbtgerlk68wl.cbetxkdyhwsb.us-east-1.rds.amazonaws.com",
user: "eff3dkg8r5y5l42x",
password: "hldf6ajnwjyzo90f",
database: "dpuui2kh95t8cclk"
});
db.connect((err) => {
if(err){
throw err;
}
console.log('Connected to database!');
});
global.db = db;
app.use(morgan('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use('/', require('./routes/index'));
app.listen(port, () => { console.log('App listening at port http://localhost:' + port + '.') });