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

initialisation du css,dependence et back #1

Merged
merged 6 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
52 changes: 48 additions & 4 deletions backend/database/schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
create table item (
id int unsigned primary key auto_increment not null,
title varchar(255) not null
);
CREATE TABLE
role (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
label VARCHAR(150)
);

CREATE TABLE
player (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
role_id INT NOT NULL,
username VARCHAR(50),
email VARCHAR(255),
password VARCHAR(128),
FOREIGN KEY (role_id) REFERENCES role(id)
);

CREATE TABLE
profile (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
bio VARCHAR(350),
avatar VARCHAR(255),
alt VARCHAR(100),
player_id_ref INT NOT NULL,
FOREIGN KEY (player_id_ref) REFERENCES player(id)
);

CREATE TABLE
game (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
name VARCHAR(50),
alt VARCHAR(50),
description VARCHAR(510),
image VARCHAR(255)
);

CREATE TABLE
party (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
player_id INT NOT NULL,
game_id INT NOT NULL,
start_time TIMESTAMP,
end_time TIMESTAMP,
is_won BOOLEAN,
player_id_ref INT NOT NULL,
game_id_ref INT NOT NULL,
FOREIGN KEY (player_id_ref) REFERENCES player(id),
FOREIGN KEY (game_id_ref) REFERENCES game(id)
);
35 changes: 35 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"test": "jest"
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"mysql2": "^3.5.2"
Expand All @@ -25,7 +26,9 @@
"supertest": "^6.3.3"
},
"lint-staged": {
"*.sql": "prettier --check",
"*.js": "eslint"
"*.js": [
"prettier --check",
"eslint"
]
}
}
25 changes: 20 additions & 5 deletions backend/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,32 @@ const seed = async () => {
// Generating Seed Data

// Optional: Truncate tables (remove existing data)
await database.query("truncate item");
// await database.query("truncate item");

// Insert fake data into the 'item' table
for (let i = 0; i < 10; i += 1) {
for (let i = 0; i < 5; i += 1) {
queries.push(
database.query("insert into item(title) values (?)", [
faker.lorem.word(),
])
database.query(
"insert into player(role_id,username, email, password) values (?,?,?,?)"
),
[
["1"],
faker.internet.userName(),
faker.internet.email(),
faker.internet.password(),
]()
);
}

// requete
// "insert into player(role_id,username, email, password) values (?,?,?,?)",
// [
// ["1"],
// faker.internet.userName(),
// faker.internet.email(),
// faker.internet.password(),
// ]

/* ************************************************************************* */

// Wait for all the insertion queries to complete
Expand Down
10 changes: 2 additions & 8 deletions backend/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@ const app = express();
// 4. Be sure to only have URLs in the array with domains from which you want to allow requests.
// For example: ["http://mysite.com", "http://another-domain.com"]

/*
const cors = require("cors");

app.use(
cors({
origin: [
process.env.FRONTEND_URL, // keep this one, after checking the value in `backend/.env`
"http://mysite.com",
"http://another-domain.com",
]
origin: [process.env.FRONTEND_URL],
})
);
*/

/* ************************************************************************* */

Expand All @@ -54,7 +48,7 @@ app.use(

// Uncomment one or more of these options depending on the format of the data sent by your client:

// app.use(express.json());
app.use(express.json());
// app.use(express.urlencoded());
// app.use(express.text());
// app.use(express.raw());
Expand Down
18 changes: 0 additions & 18 deletions backend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,4 @@ const express = require("express");

const router = express.Router();

/* ************************************************************************* */
// Define Your API Routes Here
/* ************************************************************************* */

// Import itemControllers module for handling item-related operations
const itemControllers = require("./controllers/itemControllers");

// Route to get a list of items
router.get("/items", itemControllers.browse);

// Route to get a specific item by ID
router.get("/items/:id", itemControllers.read);

// Route to add a new item
router.post("/items", itemControllers.add);

/* ************************************************************************* */

module.exports = router;
7 changes: 7 additions & 0 deletions frontend/connexion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import axios from "axios";

const connexion = axios.create({
baseURL: `${import.meta.env.VITE_BACKEND_URL}/api`,
});

export default connexion;
14 changes: 12 additions & 2 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/favicon.svg" />
<link
rel="icon"
type="image/svg+xml"
href="./src/assets/W-removebg-preview.png"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap"
rel="stylesheet"
/>
<title>Wildy Gamy</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
Expand Down
Loading