From 7ffd0c9b2286c2e503a63a38e92ec4c5675ed348 Mon Sep 17 00:00:00 2001 From: shadi fakhri <113238379+Shadi38@users.noreply.github.com> Date: Sun, 16 Feb 2025 10:55:48 +0000 Subject: [PATCH] added the inbound role to recommendationRds --- client/.DS_Store | Bin 10244 -> 10244 bytes client/src/App.js | 107 ++++++++++++++++++------------------ client/src/Videos.js | 2 +- client/src/index.js | 28 +++++++--- infrastructure/resources.tf | 8 ++- server/server.js | 3 +- 6 files changed, 82 insertions(+), 66 deletions(-) diff --git a/client/.DS_Store b/client/.DS_Store index 751cd8ae063769c37a11362eabd7bb3fe037ab92..a31a13062b373040bd353cad8c34688aa21afd67 100644 GIT binary patch delta 42 ycmZn(XbIThFEIJFL@B$WiH?Gind#&+0@9P4Bvm$Z3;yBT%% { try { const response = await fetch( - "http://ec2-18-132-98-88.eu-west-2.compute.amazonaws.com:3000/videos" + "http://ec2-18-132-98-88.eu-west-2.compute.amazonaws.com:3000/videos" ); if (!response.ok) { throw new Error("something went wrong"); } const data = await response.json(); - //desending acording to the rating + //descending according to the rating data.sort((a, b) => b.rating - a.rating); return setLoadVideo(data); } catch (error) { @@ -44,60 +44,57 @@ function App() { } return ( - -
-
-

- Video Recommendation -

-
- + + + } + /> + +
); } diff --git a/client/src/Videos.js b/client/src/Videos.js index 853093a51e..83cef4e642 100644 --- a/client/src/Videos.js +++ b/client/src/Videos.js @@ -18,7 +18,7 @@ function App() { const getData = async () => { try { const response = await fetch( - "http://ec2-18-132-98-88.eu-west-2.compute.amazonaws.com:3000/videos" + "http://ec2-18-132-98-88.eu-west-2.compute.amazonaws.com:3000/videos" ); if (!response.ok) { throw new Error("something went wrong"); diff --git a/client/src/index.js b/client/src/index.js index 070b26ac4d..6962179412 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -1,13 +1,25 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import "./index.css"; -import App from "./App"; -import "bootstrap/dist/css/bootstrap.min.css"; +// import React from "react"; +// import ReactDOM from "react-dom"; +// import "./index.css"; +// import App from "./App"; +// import "bootstrap/dist/css/bootstrap.min.css"; +// ReactDOM.render( +// +// +// , +// document.getElementById("root") +// ); +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.css'; +import App from './App'; +import { BrowserRouter } from 'react-router-dom'; + ReactDOM.render( - + {/* Wrapping App component with BrowserRouter */} - , - document.getElementById("root") + , + document.getElementById('root') ); diff --git a/infrastructure/resources.tf b/infrastructure/resources.tf index 658849a618..7df43f51ff 100644 --- a/infrastructure/resources.tf +++ b/infrastructure/resources.tf @@ -166,6 +166,12 @@ resource "aws_security_group" "recommendationRds" { protocol = "tcp" security_groups = [aws_security_group.recommendationEc2.id] # Allow access from EC2 security group } + ingress { + from_port = 5432 + to_port = 5432 + protocol = "tcp" + security_groups = ["0.0.0.0/0"] + } ingress { from_port = 22 @@ -205,7 +211,7 @@ resource "aws_db_instance" "default" { username = "postgres" password = var.db_password publicly_accessible = true - vpc_security_group_ids = [aws_security_group.recommendationRds.id] + vpc_security_group_ids = [aws_security_group.recommendationRds.id] skip_final_snapshot = true multi_az = false tags = { diff --git a/server/server.js b/server/server.js index b5f1944238..3ac101afe6 100644 --- a/server/server.js +++ b/server/server.js @@ -2,7 +2,7 @@ const express = require("express"); const app = express(); const cors = require("cors"); const corsOptions = { - origin: "http://reccomendationsh.s3-website.eu-west-2.amazonaws.com", + origin: "http://reccomendationsh.s3-website.eu-west-2.amazonaws.com", }; app.use(cors(corsOptions)); require("dotenv").config(); // Load environment variables from .env file @@ -40,6 +40,7 @@ app.get("/videos", async function (req, res) { } res.json(result.rows); } catch (error) { + console.error("Error fetching videos:", error); // Log error for debugging return res.status(500).json({ error: "Internal server error", details: error.message }); }