Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Express04 delete #114

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
APP_PORT=5000
DB_HOST=localhost
DB_PORT=3306
DB_USER=REPLACE_WITH_YOUR_USERNAME
DB_PASSWORD=REPLACE_WITH_YOUR_PASSWORD
DB_NAME=REPLACE_BY_DB_NAME
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.env
23 changes: 23 additions & 0 deletions database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require("dotenv").config();
const mysql = require("mysql2/promise");


const database = mysql.createPool({ /*Configuration pour communiquer avec ma BDD et les variables créées dans .env*/
host: process.env.DB_HOST, // address of the server
port: process.env.DB_PORT, // port of the DB server (mysql), not to be confused with the APP_PORT !
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
});

/*database
//.getConnection()
.query("select * from movies")
.then(([movies]) => {
console.log(movies);
})
.catch((err) => {
console.error(err);
});*/

module.exports = database;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const app = require("./src/app");

const port = 5000;
const port = process.env.APP_PORT ?? 5000;

app
.listen(port, () => {
Expand Down
Loading