Skip to content
Snippets Groups Projects
Commit 47a017de authored by Federico Luis Hurtado's avatar Federico Luis Hurtado
Browse files

establish connection to database.

parent 69e7e379
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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!');
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment