Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaS7 committed Jan 8, 2024
1 parent ab4994b commit 81437d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
17 changes: 2 additions & 15 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// const pool = require("./dbConfig");
const url = require('url');
const mysql = require('mysql');
const pool = require("./dbConfig");
const dotenv = require("dotenv");
dotenv.config({ path: "./env.default" });
const express = require("express");
Expand All @@ -11,21 +9,10 @@ const app = express();

app.use(cors({ origin: 'https://chuck-stewart-archive.web.app/' }));

const dbUrl = process.env.JAWSDB_URL;
const params = url.parse(dbUrl);
const auth = params.auth.split(':');

const pool = mysql.createPool({
host: params.hostname,
user: auth[0],
password: auth[1],
database: params.pathname.split('/')[1],
port: params.port,
});

app.use(express.static(path.join(__dirname, 'public')));
app.get("/", (req, res) => {
// Redirect to the login.html page
console.log("Redirecting to login.html");
res.redirect("/login.html");
});

Expand Down
30 changes: 15 additions & 15 deletions server/dbConfig.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// const mysql = require('promise-mysql2');
// require('dotenv').config();
const mysql = require('promise-mysql2');
require('dotenv').config();

// const dbConfig = {
// host: process.env.DB_HOST,
// user: process.env.DB_USER,
// password: process.env.DB_PASSWORD,
// database: process.env.DB_NAME,
// port: process.env.DB_PORT,
// authPlugins: {
// mysql_clear_password: () => () => Buffer.from(process.env.DB_PASSWORD + '\0')
// },
// insecureAuth: false
// };
const dbConfig = {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
port: process.env.DB_PORT,
authPlugins: {
mysql_clear_password: () => () => Buffer.from(process.env.DB_PASSWORD + '\0')
},
insecureAuth: false
};

// const pool = mysql.createPool(dbConfig);
const pool = mysql.createPool(dbConfig);

// module.exports = pool;
module.exports = pool;

0 comments on commit 81437d7

Please sign in to comment.