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

Express quête 07 #146

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=39942521Bw!
DB_NAME=express_quests
6 changes: 5 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
APP_PORT=5000
DB_HOST=localhost
DB_PORT=5000
DB_USER=REPLACE_WITH_YOUR_USENAME
DB_PASSWORD=REPLACE_WIH_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
41 changes: 41 additions & 0 deletions database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require("dotenv").config();

const mysql = require("mysql2/promise");

const database = mysql.createPool({
hots: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
});

database
.getConnection()
.then(() => {
console.log("Can reach database");
})
.catch((err) => {
console.error(err);
});

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

database
.query("select * from users")
.then(([users]) => {
console.log(users);
})

.catch((err) => {
console.error(err);
});

module.exports = database;
26 changes: 17 additions & 9 deletions express_quests.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Active: 1698236999326@@127.0.0.1@3306@express_quests
DROP TABLE IF EXISTS movies;

CREATE TABLE movies (
Expand Down Expand Up @@ -63,51 +64,58 @@ CREATE TABLE users (
lastname varchar(255) NOT NULL,
email varchar(255) UNIQUE NOT NULL,
city varchar(255) DEFAULT NULL,
language varchar(255) DEFAULT NULL
language varchar(255) DEFAULT NULL,
hashedPassword varchar(255) DEFAULT NOT NULL
) ENGINE = InnoDB DEFAULT CHARSET = utf8;

INSERT INTO
users (firstname, lastname, email, city, language)
users (firstname, lastname, email, city, language, hashedPassword)
VALUES
(
'John',
'Doe',
'[email protected]',
'Paris',
'English'
'English',
'$argon2id$v=19$m=16,t=2,p=1$emVmZXpmemZlemVmZWR6ZXplZg$rqZkhxu5YbqCGHPNrjJZpQ'
),
(
'Valeriy',
'Appius',
'valeriy.appius@example.com',
'valeriy.ppius@example.com',
'Moscow',
'Russian'
'Russian',
'$argon2id$v=19$m=16,t=2,p=1$emVmemVmemZlemZ6ZnpmZQ$eSetR6KPUNAGW+q+wDadcw'
),
(
'Ralf',
'Geronimo',
'[email protected]',
'New York',
'Italian'
'Italian',
'$argon2id$v=19$m=16,t=2,p=1$emVmemVmemZlemZ6ZnpmZXphZGF6ZGQ$a0bg5DZB6H6v3jjQC81DXg'
),
(
'Maria',
'Iskandar',
'[email protected]',
'New York',
'German'
'German',
'$argon2id$v=19$m=16,t=2,p=1$emVmemVmemZlenplZHpkZnpmemZlemFkYXpkZA$V1qAnJDyMuuWG7g9yoGYXA'
),
(
'Jane',
'Doe',
'[email protected]',
'London',
'English'
'English',
'$argon2id$v=19$m=16,t=2,p=1$emVmemVmemZlenplZHpkZGZ6ZnpmZXphZGF6ZGQ$VCzq45PL9t8khtc44Kk5iw'
),
(
'Johanna',
'Martino',
'[email protected]',
'Milan',
'Spanish'
'Spanish',
'$argon2id$v=19$m=16,t=2,p=1$emVmemVmemVmemZlenplZHpkZGZ6ZnpmZXphZGF6ZGQ$UKaGZ9hGFn/S5SBQDMe/Uw'
);
Loading