From 47a017de6bc84c5cd2af46371c7964938e0de63c Mon Sep 17 00:00:00 2001
From: Federico Luis Hurtado <fhurtado14@beech.rlogin>
Date: Mon, 30 Sep 2024 12:12:14 -0400
Subject: [PATCH] establish connection to database.

---
 Dockerfile |  2 +-
 index.js   | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index d62d43c..d58dc52 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,7 +5,7 @@ FROM node:14
 WORKDIR /app
 
 # Copy package.json and install dependencies
-COPY package.json /app
+COPY package*.json /app
 RUN npm install
 
 
diff --git a/index.js b/index.js
index 7ac4efd..01276f1 100644
--- a/index.js
+++ b/index.js
@@ -1,10 +1,39 @@
 const express = require('express');
+const mysql = require('mysql2');
+
 
 const app = express();
+app.use(express.json())
+
+// MySQL Database connection setup
+const db = mysql.createConnection({
+    host: 'mariadb',              
+    user: 'corps-directory-dev',   
+    password: 'corps-password',    
+    database: 'corps-directory-db' 
+  });
+
+  // Connect to the database
+db.connect(err => {
+    if (err) {
+      console.error('Error connecting to MySQL:', err);
+      return;
+    }
+    console.log('Connected to MySQL');
+  });
 
 const port = process.env.PORT || 3000;
 
 
+
+
+
+
+
+
+
+
+
 app.get('/', (req, res) => {
   res.send('Hello World!');
 });
-- 
GitLab