prod124njac/prod124njac-back-b/authsec_node/Backend/config/database.js

26 lines
652 B
JavaScript
Raw Normal View History

2024-09-18 04:14:45 +00:00
const mysql = require("mysql2")
const mysqlProm = require("mysql2/promise")
const pool = mysql.createConnection({
host: process.env.DATABASE_HOST,
port: process.env.DATABASE_PORT,
database: process.env.DATABASE_NAME,
user: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
})
const db = mysqlProm.createPool({
host: process.env.DATABASE_HOST,
port: process.env.DATABASE_PORT,
database: process.env.DATABASE_NAME,
user: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
})
pool.connect(function (err) {
if (err) throw err
console.log("Connected!")
})
module.exports = { pool, db }