From fe7135ea4eb4f1bce0d51268e643df891094209c Mon Sep 17 00:00:00 2001
From: epicfahimxd <40809642+epicfahimxd@users.noreply.github.com>
Date: Sun, 27 Oct 2024 20:23:45 -0400
Subject: [PATCH 1/7] class schema de
---
backend/server.js | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/backend/server.js b/backend/server.js
index 80539c5..5c52976 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -47,6 +47,19 @@ const User = mongoose.model("users", UserSchema)
// Class Schema
// TODO (Claire & Fahim): Create a ClassSchema
+const ClassSchema = new Schema({
+ id: {type: String, required: true},
+ title: {type: String, required: true},
+ level: {type: String, required: true},
+ ageGroup: {type: String, required: true},
+ instructor: {type: String, required: true},
+ schedule: {type: [String], required:true},
+})
+const Class = mongoose.model("class", ClassSchema)
+const math = new ClassSchema({id: "43", title: "claire", level: "100", ageGroup: "7", instructor: "fahimrbarh", schedule: ["3",'4']})
+console.log(math.id)
+
+
//------------------ ENDPOINTS ------------------//
@@ -68,4 +81,7 @@ const User = mongoose.model("users", UserSchema)
// Classes
-// TODO (Claire & Fahim): Create an endpoint to retrieve class data from the database
\ No newline at end of file
+// TODO (Claire & Fahim): Create an endpoint to retrieve class data from the database
+app.get('/', (req, res)=>{
+ res.send("deez")
+})
\ No newline at end of file
From da80679219740e7685e1fde7ec189df32f5a0064 Mon Sep 17 00:00:00 2001
From: epicfahimxd <40809642+epicfahimxd@users.noreply.github.com>
Date: Sat, 2 Nov 2024 14:07:33 -0400
Subject: [PATCH 2/7] issues with env
---
backend/server.js | 24 +++++++++++++++++-------
package-lock.json | 12 ++++++++++++
package.json | 1 +
src/pages/Home.jsx | 10 ++++++++++
4 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/backend/server.js b/backend/server.js
index 5c52976..cb63a1e 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -1,15 +1,17 @@
+require('dotenv').config();
const express = require('express');
const cors = require('cors')
const mongo = require("mongodb");
const mongoose = require("mongoose");
-require('dotenv').config();
+console.log(process.env)
const app = express()
app.use(cors())
app.use(express.json())
-
+// console.log('MongoDB URI:', process.env.MONGODB_URI);
+// console.log(process.env.PORT);
+//ERROR ERRO ERROR .ENV FILE DOES NOT CONNECT
const PORT = process.env.PORT || 4000;
-
mongoose.connect(process.env.MONGODB_URI)
.then(() => {
app.listen(PORT, () => {
@@ -56,8 +58,9 @@ const ClassSchema = new Schema({
schedule: {type: [String], required:true},
})
const Class = mongoose.model("class", ClassSchema)
-const math = new ClassSchema({id: "43", title: "claire", level: "100", ageGroup: "7", instructor: "fahimrbarh", schedule: ["3",'4']})
-console.log(math.id)
+//testing
+// const math = new ClassSchema({id: "43", title: "claire", level: "100", ageGroup: "7", instructor: "fahimrbarh", schedule: ["3",'4']})
+// console.log(math.id)
@@ -82,6 +85,13 @@ console.log(math.id)
// Classes
// TODO (Claire & Fahim): Create an endpoint to retrieve class data from the database
-app.get('/', (req, res)=>{
- res.send("deez")
+app.get('/data', async (req, res)=>{
+ console.log("endpoint is being hit")
+ try {
+ const data = await Class.find(); // Replace YourModel with your actual model
+ res.json(data);
+ console.log(data);
+ } catch (err) {
+ res.status(500).send(err);
+ }
})
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 8f95748..65a0e25 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,6 +8,7 @@
"name": "dillar-academy",
"version": "0.0.0",
"dependencies": {
+ "dotenv": "^16.4.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
@@ -1953,6 +1954,17 @@
"node": ">=0.10.0"
}
},
+ "node_modules/dotenv": {
+ "version": "16.4.5",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
+ "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://dotenvx.com"
+ }
+ },
"node_modules/eastasianwidth": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
diff --git a/package.json b/package.json
index ecb9b67..819c84e 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
+ "dotenv": "^16.4.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx
index e69de29..7a733d8 100644
--- a/src/pages/Home.jsx
+++ b/src/pages/Home.jsx
@@ -0,0 +1,10 @@
+
+function Home() {
+ return (
+ <>
+
Hello Everyone
+ >
+ )
+}
+
+export default Home
From 6274e7adea2d85fc2243707c292ffd628bb31094 Mon Sep 17 00:00:00 2001
From: myix765
Date: Sat, 2 Nov 2024 14:21:46 -0400
Subject: [PATCH 3/7] mongo connection configuration
---
.vercel/README.txt | 11 +++++++++++
.vercel/project.json | 1 +
backend/server.js | 31 ++++++++++++++++++++++---------
3 files changed, 34 insertions(+), 9 deletions(-)
create mode 100644 .vercel/README.txt
create mode 100644 .vercel/project.json
diff --git a/.vercel/README.txt b/.vercel/README.txt
new file mode 100644
index 0000000..525d8ce
--- /dev/null
+++ b/.vercel/README.txt
@@ -0,0 +1,11 @@
+> Why do I have a folder named ".vercel" in my project?
+The ".vercel" folder is created when you link a directory to a Vercel project.
+
+> What does the "project.json" file contain?
+The "project.json" file contains:
+- The ID of the Vercel project that you linked ("projectId")
+- The ID of the user or team your Vercel project is owned by ("orgId")
+
+> Should I commit the ".vercel" folder?
+No, you should not share the ".vercel" folder with anyone.
+Upon creation, it will be automatically added to your ".gitignore" file.
diff --git a/.vercel/project.json b/.vercel/project.json
new file mode 100644
index 0000000..6ce3832
--- /dev/null
+++ b/.vercel/project.json
@@ -0,0 +1 @@
+{"orgId":"team_ZUrHyE7wLz26UE18gfmnufvV","projectId":"prj_Ss73k2c7RyLNVOjy4WAkQeu50x6C"}
\ No newline at end of file
diff --git a/backend/server.js b/backend/server.js
index cb63a1e..2f6c528 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -3,7 +3,7 @@ const express = require('express');
const cors = require('cors')
const mongo = require("mongodb");
const mongoose = require("mongoose");
-console.log(process.env)
+// console.log(process.env)
const app = express()
app.use(cors())
@@ -13,14 +13,27 @@ app.use(express.json())
//ERROR ERRO ERROR .ENV FILE DOES NOT CONNECT
const PORT = process.env.PORT || 4000;
mongoose.connect(process.env.MONGODB_URI)
- .then(() => {
- app.listen(PORT, () => {
- console.log(`Server listening on port ${PORT}`)
- });
- })
- .catch((e) => {
- console.log(e)
- })
+ .then(() => {
+ console.log('Successfully connected to MongoDB database:', mongoose.connection.name);
+ const server = app.listen(PORT, () => {
+ console.log(`Server listening on port ${PORT}`);
+ }).on('error', (err) => {
+ if (err.code === 'EADDRINUSE') {
+ console.log(`Port ${PORT} is busy, trying ${PORT + 1}`);
+ server.listen(PORT + 1);
+ } else {
+ console.error('Server error:', err);
+ }
+ });
+ })
+ .catch((error) => {
+ console.error('MongoDB connection error:', error.message);
+ process.exit(1); // Exit if we can't connect to the database
+ });
+
+mongoose.connection.on('error', (err) => {
+ console.error('MongoDB connection error:', err);
+});
app.get('/', (req, res) => {
res.send('Server is running!')
From fc88b0552c331d880755df9dfe7cb69a1333dbea Mon Sep 17 00:00:00 2001
From: epicfahimxd <40809642+epicfahimxd@users.noreply.github.com>
Date: Sat, 2 Nov 2024 16:27:54 -0400
Subject: [PATCH 4/7] We finished getting the data in
---
backend/server.js | 10 +++---
package-lock.json | 91 +++++++++++++++++++++++++++++++++++++++++++++++
package.json | 1 +
src/App.jsx | 40 +++++++++++++++++++--
4 files changed, 135 insertions(+), 7 deletions(-)
diff --git a/backend/server.js b/backend/server.js
index 2f6c528..6c06d28 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -63,7 +63,7 @@ const User = mongoose.model("users", UserSchema)
// TODO (Claire & Fahim): Create a ClassSchema
const ClassSchema = new Schema({
- id: {type: String, required: true},
+ _id: {type: String, required: true},
title: {type: String, required: true},
level: {type: String, required: true},
ageGroup: {type: String, required: true},
@@ -97,13 +97,15 @@ const Class = mongoose.model("class", ClassSchema)
// Classes
+//schema for adding manipulatn and querying from database and specifies where and whichd database, middleware helps with interacting with mongo
// TODO (Claire & Fahim): Create an endpoint to retrieve class data from the database
-app.get('/data', async (req, res)=>{
+app.get('/api/data', async (req, res)=>{
console.log("endpoint is being hit")
try {
- const data = await Class.find(); // Replace YourModel with your actual model
- res.json(data);
+ const data = await Class.find();
+ // res.json(data);
console.log(data);
+ res.json(data)
} catch (err) {
res.status(500).send(err);
}
diff --git a/package-lock.json b/package-lock.json
index 65a0e25..a326927 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,6 +8,7 @@
"name": "dillar-academy",
"version": "0.0.0",
"dependencies": {
+ "axios": "^1.7.7",
"dotenv": "^16.4.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
@@ -1523,6 +1524,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+ },
"node_modules/autoprefixer": {
"version": "10.4.20",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.20.tgz",
@@ -1575,6 +1581,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/axios": {
+ "version": "1.7.7",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
+ "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
+ "dependencies": {
+ "follow-redirects": "^1.15.6",
+ "form-data": "^4.0.0",
+ "proxy-from-env": "^1.1.0"
+ }
+ },
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -1769,6 +1785,17 @@
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
"dev": true
},
+ "node_modules/combined-stream": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
+ "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+ "dependencies": {
+ "delayed-stream": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
"node_modules/commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
@@ -1930,6 +1957,14 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
"node_modules/didyoumean": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz",
@@ -2595,6 +2630,25 @@
"integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==",
"dev": true
},
+ "node_modules/follow-redirects": {
+ "version": "1.15.9",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
+ "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://github.com/sponsors/RubenVerborgh"
+ }
+ ],
+ "engines": {
+ "node": ">=4.0"
+ },
+ "peerDependenciesMeta": {
+ "debug": {
+ "optional": true
+ }
+ }
+ },
"node_modules/for-each": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
@@ -2620,6 +2674,19 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/form-data": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz",
+ "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
+ "dependencies": {
+ "asynckit": "^0.4.0",
+ "combined-stream": "^1.0.8",
+ "mime-types": "^2.1.12"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
"node_modules/fraction.js": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz",
@@ -3546,6 +3613,25 @@
"node": ">=8.6"
}
},
+ "node_modules/mime-db": {
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+ "dependencies": {
+ "mime-db": "1.52.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
@@ -4086,6 +4172,11 @@
"react-is": "^16.13.1"
}
},
+ "node_modules/proxy-from-env": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
+ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
+ },
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
diff --git a/package.json b/package.json
index 819c84e..be3dbee 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
+ "axios": "^1.7.7",
"dotenv": "^16.4.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
diff --git a/src/App.jsx b/src/App.jsx
index db1322a..aee2a84 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,12 +1,46 @@
import './App.css'
import Home from './pages/Home'
+import axios from 'axios';
+import { useState, useEffect } from 'react';
+const CourseList = () => {
+ const [courses, setCourses] = useState([]);
+
+ useEffect(() => {
+ const fetchCourses = async () => {
+ try {
+ const response = await axios.get('http://localhost:4000/api/data');
+ setCourses(response.data);
+ console.log(response.data)
+ } catch (error) {
+ console.error('Error fetching courses:', error);
+ }
+ };
+ fetchCourses();
+ }, []);
+ return (
+
+
Course List
+ {courses.length === 0 ? (
+
Loading courses...
+ ) : (
+
+ {courses.map(course => (
+ -
+ {course.title} (Level: {course.level}, Instructor: {course.instructor})
+
+ ))}
+
+ )}
+
+ );
+}
function App() {
return (
- <>
-
- >
+
+
+
)
}
From 1c76a70e56678f995ccbd3fc26774146bb8838c5 Mon Sep 17 00:00:00 2001
From: myix765 <80227988+myix765@users.noreply.github.com>
Date: Sat, 2 Nov 2024 17:37:22 -0400
Subject: [PATCH 5/7] Delete .vercel/project.json
---
.vercel/project.json | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 .vercel/project.json
diff --git a/.vercel/project.json b/.vercel/project.json
deleted file mode 100644
index 6ce3832..0000000
--- a/.vercel/project.json
+++ /dev/null
@@ -1 +0,0 @@
-{"orgId":"team_ZUrHyE7wLz26UE18gfmnufvV","projectId":"prj_Ss73k2c7RyLNVOjy4WAkQeu50x6C"}
\ No newline at end of file
From 9b588518098abc7fd54dec06abe7ede5f91f35b0 Mon Sep 17 00:00:00 2001
From: myix765 <80227988+myix765@users.noreply.github.com>
Date: Sat, 2 Nov 2024 17:37:43 -0400
Subject: [PATCH 6/7] Delete .vercel/README.txt
---
.vercel/README.txt | 11 -----------
1 file changed, 11 deletions(-)
delete mode 100644 .vercel/README.txt
diff --git a/.vercel/README.txt b/.vercel/README.txt
deleted file mode 100644
index 525d8ce..0000000
--- a/.vercel/README.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-> Why do I have a folder named ".vercel" in my project?
-The ".vercel" folder is created when you link a directory to a Vercel project.
-
-> What does the "project.json" file contain?
-The "project.json" file contains:
-- The ID of the Vercel project that you linked ("projectId")
-- The ID of the user or team your Vercel project is owned by ("orgId")
-
-> Should I commit the ".vercel" folder?
-No, you should not share the ".vercel" folder with anyone.
-Upon creation, it will be automatically added to your ".gitignore" file.
From 22463e8d14ee1a360edb615c2926c470df230773 Mon Sep 17 00:00:00 2001
From: myix765
Date: Sat, 2 Nov 2024 17:43:53 -0400
Subject: [PATCH 7/7] add classes to navbar
---
src/components/NavBar/NavBar.jsx | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/components/NavBar/NavBar.jsx b/src/components/NavBar/NavBar.jsx
index 239b4c2..9ea8f73 100644
--- a/src/components/NavBar/NavBar.jsx
+++ b/src/components/NavBar/NavBar.jsx
@@ -19,6 +19,7 @@ const NavBar = () => {
About
Contact
+ Classes
Sign Up
{/* */}
@@ -42,6 +43,7 @@ const NavBar = () => {
About
Contact
+ Classes
Sign Up