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

Dev #31

Closed
wants to merge 91 commits into from
Closed

Dev #31

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
fb71b0b
j'ai rien compris
Dreallers Dec 12, 2023
b6b4e9f
Merge branch 'dev' of github.com:Dreallers/WildTube into test
Dreallers Dec 12, 2023
2bef70d
cest nul
Dreallers Dec 12, 2023
6aae885
Merge branch 'dev' of github.com:Dreallers/WildTube into test
Dreallers Dec 12, 2023
c5a99aa
structure database
Aurelemeriau Dec 12, 2023
f766e99
Merge pull request #7 from Dreallers/Aurel
Aurelemeriau Dec 12, 2023
cad74ff
working on backend...
Ange230700 Dec 12, 2023
cd79618
fixing conflicts
Ange230700 Dec 12, 2023
60e85f6
pending...
Ange230700 Dec 12, 2023
5c787ef
pulling dev
Dreallers Dec 12, 2023
24ea0c0
pulling dev
Dreallers Dec 12, 2023
e025d59
config table User
Aurelemeriau Dec 12, 2023
bff7f8b
import userManager
Aurelemeriau Dec 12, 2023
880502d
FilmManager creation
Dreallers Dec 12, 2023
ce2061a
Merge pull request #8 from Dreallers/CRUD_film
Dreallers Dec 12, 2023
0fbf442
gestion conflits
Aurelemeriau Dec 12, 2023
7e6f806
Merge pull request #10 from Dreallers/S1_configTableUser
Aurelemeriau Dec 12, 2023
49912df
SerieManager
Tony97421 Dec 12, 2023
6ecd7ca
Merge branch 'dev' into s01SerieManager
Tony97421 Dec 12, 2023
d6b8c50
Merge pull request #11 from Dreallers/s01SerieManager
Tony97421 Dec 12, 2023
0b0149d
working on backend
Ange230700 Dec 12, 2023
bd56b2d
fixing conflicts
Ange230700 Dec 12, 2023
c9a8f7f
Merge pull request #12 from Dreallers/express-server
Ange230700 Dec 12, 2023
7a350f5
working on backend
Ange230700 Dec 12, 2023
926fbbd
Merge pull request #13 from Dreallers/express-server
Ange230700 Dec 13, 2023
d49ad1b
modif usercontrollers
Aurelemeriau Dec 13, 2023
083180c
merging
Dreallers Dec 13, 2023
6f0013b
merging
Dreallers Dec 13, 2023
eb9bec2
Merge pull request #15 from Dreallers/CRUD_film
Dreallers Dec 13, 2023
fb45cc6
commit avant pull
Aurelemeriau Dec 13, 2023
a23ec9b
Merge branch 'dev' of github.com:Dreallers/WildTube into S1_testFront
Aurelemeriau Dec 13, 2023
0ee8f61
serieControllers
Tony97421 Dec 13, 2023
066810d
Merge pull request #16 from Dreallers/s01serieControllers
Tony97421 Dec 13, 2023
f0c306c
route for Controllers
Tony97421 Dec 13, 2023
b8a746a
Merge pull request #17 from Dreallers/s01routeBackEnd
Tony97421 Dec 13, 2023
4392f0d
usercontrollers
Aurelemeriau Dec 13, 2023
5d81c6a
merging
Dreallers Dec 13, 2023
14edb95
Merge branch 'dev' of github.com:Dreallers/WildTube into CRUD_film
Dreallers Dec 13, 2023
154e055
update film ok
Dreallers Dec 13, 2023
c780fc7
Merge pull request #18 from Dreallers/CRUD_film
Dreallers Dec 13, 2023
24146bc
pending...
Ange230700 Dec 13, 2023
06ae0df
fixing conflicts
Ange230700 Dec 13, 2023
6f1f05b
crud_film done
Dreallers Dec 13, 2023
a118ed3
Merge pull request #19 from Dreallers/CRUD_film
Dreallers Dec 13, 2023
3b2355d
modif routes
Aurelemeriau Dec 13, 2023
8f26824
working on backend controllers and managers
Ange230700 Dec 13, 2023
7a213b8
routes users OK
Aurelemeriau Dec 13, 2023
0e60fe4
Merge pull request #20 from Dreallers/S1_testFront
Aurelemeriau Dec 13, 2023
4bf25ad
merging
Dreallers Dec 13, 2023
88472af
Merge branch 'dev' of github.com:Dreallers/WildTube into CRUD_film
Dreallers Dec 13, 2023
ec13ca9
working on backend controllers and managers part 2
Ange230700 Dec 13, 2023
026d91f
trying to do JOIN SQL request...
Ange230700 Dec 13, 2023
b6cba8d
toutes les routes series fonctionnent :)
Tony97421 Dec 13, 2023
9d85fce
Merge branch 'dev' into s01routeBackEnd
Tony97421 Dec 13, 2023
ea06622
Merge pull request #21 from Dreallers/s01routeBackEnd
Tony97421 Dec 13, 2023
358f9e1
creating react routes
Ange230700 Dec 13, 2023
6623fb1
pending...
Ange230700 Dec 13, 2023
f61f432
fixing conflicts
Ange230700 Dec 13, 2023
6cd8201
Merge pull request #22 from Dreallers/sprint01-express-server
Ange230700 Dec 13, 2023
e3eb072
merging
Dreallers Dec 13, 2023
0231cd7
table films en tendance
Aurelemeriau Dec 13, 2023
05c97cb
done
Dreallers Dec 13, 2023
c51508c
Merge pull request #23 from Dreallers/CRUD_favorite
Dreallers Dec 13, 2023
fc9092e
conflicts
Dreallers Dec 13, 2023
1cd3a9e
Merge pull request #24 from Dreallers/CRUD_favorite
Tony97421 Dec 13, 2023
99cfa70
commit avant pull
Aurelemeriau Dec 13, 2023
240d627
pending...
Ange230700 Dec 13, 2023
99f851e
pending...
Ange230700 Dec 13, 2023
fb479e9
fixing conflicts...
Ange230700 Dec 13, 2023
fd21da4
handling the context API
Ange230700 Dec 13, 2023
f3f714e
handling useParams
Ange230700 Dec 14, 2023
79b1f66
table films en tendance
Aurelemeriau Dec 14, 2023
c57dde2
Merge pull request #25 from Dreallers/sprint01-express-server
Ange230700 Dec 14, 2023
2e2e1a3
route films en tendance et database films pour front
Aurelemeriau Dec 14, 2023
e62e406
Merge pull request #26 from Dreallers/S1_tableJointure
Ange230700 Dec 14, 2023
ab77b36
favori_serie controller manager table et route
Tony97421 Dec 14, 2023
6541d4d
Merge branch 'dev' of github.com:Dreallers/WildTube into s01favoriSer…
Tony97421 Dec 14, 2023
2813bd5
implementing movie page
Ange230700 Dec 14, 2023
00cd81f
adding video field in movie table
Ange230700 Dec 14, 2023
e00a3a6
fixing conflicts
Ange230700 Dec 14, 2023
8b50fc1
working on video player
Ange230700 Dec 14, 2023
7a3ce03
updating
Ange230700 Dec 14, 2023
2a9bfc1
jointure favori serie ok
Tony97421 Dec 15, 2023
bf74610
Merge pull request #27 from Dreallers/s01favoriSerieController
Ange230700 Dec 15, 2023
e166c85
pending...
Ange230700 Dec 15, 2023
337cab9
pending...
Ange230700 Dec 15, 2023
776bcc9
pending...
Ange230700 Dec 15, 2023
24066d3
fixing conflicts
Ange230700 Dec 15, 2023
11409a1
Merge pull request #29 from Dreallers/sprint01-movie-page-front
Aurelemeriau Dec 15, 2023
b75bd32
...
Ange230700 Dec 15, 2023
7686ace
Merge pull request #30 from Dreallers/sprint01-movie-page-front
Aurelemeriau Dec 15, 2023
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
1 change: 1 addition & 0 deletions backend/database/client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require("dotenv").config();
// Get variables from .env file for database connection
const { DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME } = process.env;

Expand Down
336 changes: 283 additions & 53 deletions backend/database/schema.sql

Large diffs are not rendered by default.

Binary file removed backend/public/assets/images/favicon.png
Binary file not shown.
30 changes: 23 additions & 7 deletions backend/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,31 @@ const seed = async () => {

// Generating Seed Data

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

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

for (let numberOfData = 0; numberOfData < 100; numberOfData += 1) {
queries.push(
database.query("insert into item(title) values (?)", [
faker.lorem.word(),
])
database.query(
"INSERT INTO `Film` (`miniature`, `title`, `duration`, `year`, `description`, `is_available`) VALUES (?, ?, ?, ?, ?, ?)",
[
faker.image.imageUrl(),
faker.lorem.words(),
faker.datatype.number(),
faker.datatype.number(),
faker.lorem.paragraph(),
faker.datatype.boolean(),
]
)
);
}

Expand Down
44 changes: 22 additions & 22 deletions backend/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ 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",
// ],
// })
// );
const cors = require("cors"); // eslint-disable-line

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

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

// Request Parsing: Understanding the purpose of this part
Expand All @@ -52,9 +52,9 @@ const app = express();
// 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.urlencoded());
app.use(express.text());
app.use(express.raw());
// app.use(express.urlencoded());
// app.use(express.text());
// app.use(express.raw());

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

Expand All @@ -69,7 +69,7 @@ app.use(express.raw());

// Then, require the module and use it as middleware in your Express application:

// const cookieParser = require("cookie-parser");
// const cookieParser = require("cookie-parser"); // eslint-disable-line

// app.use(cookieParser());

Expand Down Expand Up @@ -106,17 +106,17 @@ app.use("/api", router);
// 1. Uncomment the lines related to serving static files and redirecting unhandled requests.
// 2. Ensure that the `reactBuildPath` points to the correct directory where your frontend's build artifacts are located.

const reactBuildPath = `${__dirname}/../../frontend/dist`;
// const reactBuildPath = `${__dirname}/../../frontend/dist`;

// Serve react resources
// // Serve react resources

app.use(express.static(reactBuildPath));
app.use(express.static("./public"));

// Redirect unhandled requests to the react index file
// // Redirect unhandled requests to the react index file

app.get("*", (req, res) => {
res.sendFile(`${reactBuildPath}/index.html`);
});
// app.get("*", (req, res) => {
// res.sendFile(`${reactBuildPath}/index.html`);
// });

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

Expand Down
109 changes: 109 additions & 0 deletions backend/src/controllers/categorieControllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Import access to database tables
const tables = require("../tables");

// The B of BREAD - Browse (Read All) operation
const browse = async (request, response, next) => {
try {
// Fetch all items from the database
const categories = await tables.categorie.readAll();

// Respond with the items in JSON format
response.json(categories);
} catch (error) {
// Pass any errors to the error-handling middleware
next(error);
}
};

// The R of BREAD - Read operation
const read = async (request, response, next) => {
try {
// Fetch a specific item from the database based on the provided ID
const categorie = await tables.categorie.read(request.params.id);

// If the item is not found, respond with HTTP 404 (Not Found)
// Otherwise, respond with the item in JSON format
if (categorie == null) {
response.sendStatus(404);
} else {
response.json(categorie);
}
} catch (error) {
// Pass any errors to the error-handling middleware
next(error);
}
};

// The E of BREAD - Edit (Update) operation
const edit = async (request, response, next) => {
// Extract the ID of the item to be updated from the request parameters
const { id } = request.params;

// Add the ID to the item data extracted from the request body
request.body.id = id;

try {
// Update the item in the database
const result = await tables.categorie.update(request.body);

// If the item is not found, respond with HTTP 404 (Not Found)
// Otherwise, respond with HTTP 204 (No Content)
if (result) {
response.json(result);
response.sendStatus(204);
} else {
response.sendStatus(404);
}
} catch (err) {
// Pass any errors to the error-handling middleware
next(err);
}
};

// The A of BREAD - Add (Create) operation
const add = async (request, response, next) => {
// Extract the item data from the request body
const categorie = request.body;

try {
// Insert the item into the database
const insertId = await tables.categorie.create(categorie);

// Respond with HTTP 201 (Created) and the ID of the newly inserted item
response.status(201).json({ insertId });
} catch (err) {
// Pass any errors to the error-handling middleware
next(err);
}
};

// The D of BREAD - Destroy (Delete) operation
const destroy = async (request, response, next) => {
// Extract the ID of the item to be deleted from the request parameters
const { id } = request.params.id;

try {
// Delete the item from the database
const result = await tables.categorie.delete(id);

// If the item is not found, respond with HTTP 404 (Not Found)
// Otherwise, respond with HTTP 200 (OK)
if (result.affectedRows) {
response.sendStatus(200);
} else {
response.sendStatus(404);
}
} catch (err) {
// Pass any errors to the error-handling middleware
next(err);
}
};

// Ready to export the controller functions
module.exports = {
browse,
read,
edit,
add,
destroy,
};
81 changes: 81 additions & 0 deletions backend/src/controllers/categorieParFilmControllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Import access to database tables
const tables = require("../tables");

// The B of BREAD - Browse (Read All) operation
const browseCategoriesForSpecificFilm = async (request, response, next) => {
try {
// Fetch all items from the database
const categories =
await tables.categorieParFilm.readAllCategoriesForSpecificFilm(
request.params.id
);

// Respond with the items in JSON format
response.json(categories);
} catch (error) {
// Pass any errors to the error-handling middleware
next(error);
}
};

const browseFilmsForSpecificCategorie = async (request, response, next) => {
try {
// Fetch all items from the database
const films =
await tables.categorieParFilm.readAllFilmsForSpecificCategorie(
request.params.id
);

// Respond with the items in JSON format
response.json(films);
} catch (error) {
// Pass any errors to the error-handling middleware
next(error);
}
};

// The A of BREAD - Add operation
const add = async (request, response, next) => {
const { filmId, categorieId } = request.body;

try {
// Insert the new item into the database
const id = await tables.categorieParFilm.create({ filmId, categorieId });

// Fetch the newly created item from the database
const categorieParFilm = await tables.categorieParFilm.read(id);

// Respond with the newly created item in JSON format
response.json(categorieParFilm);
} catch (error) {
// Pass any errors to the error-handling middleware
next(error);
}
};

// The D of BREAD - Delete operation
const destroy = async (request, response, next) => {
try {
// Delete the item from the database
const result = await tables.categorieParFilm.delete(request.params.id);

// If the item is not found, respond with HTTP 404 (Not Found)
// Otherwise, respond with HTTP 204 (No Content)
if (result) {
response.sendStatus(204);
} else {
response.sendStatus(404);
}
} catch (error) {
// Pass any errors to the error-handling middleware
next(error);
}
};

// Ready to export the controller functions
module.exports = {
browseCategoriesForSpecificFilm,
browseFilmsForSpecificCategorie,
add,
destroy,
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const tables = require("../tables");
const browse = async (req, res, next) => {
try {
// Fetch all items from the database
const items = await tables.item.readAll();
const tendances = await tables.En_Tendance_Film.readAll();

// Respond with the items in JSON format
res.json(items);
res.json(tendances);
} catch (err) {
// Pass any errors to the error-handling middleware
next(err);
Expand All @@ -19,14 +19,14 @@ const browse = async (req, res, next) => {
const read = async (req, res, next) => {
try {
// Fetch a specific item from the database based on the provided ID
const item = await tables.item.read(req.params.id);
const tendances = await tables.En_Tendance_Film.read(req.params.id);

// If the item is not found, respond with HTTP 404 (Not Found)
// Otherwise, respond with the item in JSON format
if (item == null) {
if (tendances == null) {
res.sendStatus(404);
} else {
res.json(item);
res.json(tendances);
}
} catch (err) {
// Pass any errors to the error-handling middleware
Expand All @@ -40,14 +40,14 @@ const read = async (req, res, next) => {
// The A of BREAD - Add (Create) operation
const add = async (req, res, next) => {
// Extract the item data from the request body
const item = req.body;
const tendances = req.body;

try {
// Insert the item into the database
const insertId = await tables.item.create(item);
const insertId = await tables.En_Tendance_Film.create(tendances);

// Respond with HTTP 201 (Created) and the ID of the newly inserted item
res.status(201).json({ insertId });
res.status(200).json({ insertId });
} catch (err) {
// Pass any errors to the error-handling middleware
next(err);
Expand All @@ -56,12 +56,25 @@ const add = async (req, res, next) => {

// The D of BREAD - Destroy (Delete) operation
// This operation is not yet implemented
const destroy = async (req, res, next) => {
const { id: userId } = req.params;
const { filmId } = req.body;
try {
const [result] = await tables.En_Tendance_Film.delete(userId, filmId);
if (result.affectedRows) {
res.sendStatus(200);
} else {
res.sendStatus(404);
}
} catch (err) {
next(err);
}
};

// Ready to export the controller functions
module.exports = {
browse,
read,
// edit,
add,
// destroy,
destroy,
};
Loading