-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.js
44 lines (41 loc) · 1.11 KB
/
Server.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
36
37
38
39
40
41
42
43
44
import dotenv from 'dotenv'
import mysql from 'mysql'
import express from 'express'
var app = express()
import path from 'path'
import router from './route.js'
import cors from 'cors'
import bodyParser from 'body-parser'
dotenv.config()
const PORT = process.env.PORT
const con = mysql.createConnection({
host: "database-1.cvtayqzstpus.ap-south-1.rds.amazonaws.com",
port:'3306',
user: "admin",
password: "password",
database: "rds_db"
});
con.connect(function (err) {
// const sql ="DELETE FROM new_account";
// con.query(sql,()=>{
// console.log("DELETED....");
// })
if (err) throw err;
console.log("Connected!");
});
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(express.json())
app.use(cors())
app.use('/', router)
router.options('/', cors())
// if(process.env.NODE_ENV == 'production'){
// app.use(express.static('frontend/build'));
// app.get('*',(req,res)=>{
// res.sendFile(path.resolve(__dirname,'frontend','build','index.html'))
// })
// }
app.listen(PORT, function () {
console.log(`server is running on port ${PORT}`);
})
export default con;