diff --git a/client/avatars/carmen.png b/client/avatars/carmen.png new file mode 100644 index 0000000..96e9307 Binary files /dev/null and b/client/avatars/carmen.png differ diff --git a/client/avatars/jacquilyn.png b/client/avatars/jacquilyn.png new file mode 100644 index 0000000..67fc164 Binary files /dev/null and b/client/avatars/jacquilyn.png differ diff --git a/client/avatars/michael.png b/client/avatars/michael.png new file mode 100644 index 0000000..d66aa0f Binary files /dev/null and b/client/avatars/michael.png differ diff --git a/client/avatars/shawna.png b/client/avatars/shawna.png new file mode 100644 index 0000000..9bc1caf Binary files /dev/null and b/client/avatars/shawna.png differ diff --git a/client/avatars/trevor.png b/client/avatars/trevor.png new file mode 100644 index 0000000..f730838 Binary files /dev/null and b/client/avatars/trevor.png differ diff --git a/client/package-lock.json b/client/package-lock.json index cf4bd40..f10dbcf 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -12,7 +12,8 @@ "howler": "^2.2.4", "lucide-react": "^0.503.0", "react": "^19.1.0", - "react-dom": "^19.0.0" + "react-dom": "^19.0.0", + "react-router-dom": "^6.30.0" }, "devDependencies": { "@eslint/js": "^9.21.0", @@ -20,6 +21,7 @@ "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", "@types/react-howler": "^5.2.3", + "@types/react-router-dom": "^5.3.3", "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.21", "eslint": "^9.21.0", @@ -1406,6 +1408,15 @@ } } }, + "node_modules/@remix-run/router": { + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.0.tgz", + "integrity": "sha512-O3rHJzAQKamUz1fvE0Qaw0xSFqsA/yafi2iqeE0pvdFtCO1viYx8QL6f3Ln/aCCTLxs68SLf0KPM9eSeM8yBnA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.40.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.0.tgz", @@ -2006,6 +2017,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/history": { + "version": "4.7.11", + "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", + "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/howler": { "version": "2.2.12", "resolved": "https://registry.npmjs.org/@types/howler/-/howler-2.2.12.tgz", @@ -2051,6 +2069,29 @@ "@types/react": "*" } }, + "node_modules/@types/react-router": { + "version": "5.1.20", + "resolved": "https://registry.npmjs.org/@types/react-router/-/react-router-5.1.20.tgz", + "integrity": "sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/history": "^4.7.11", + "@types/react": "*" + } + }, + "node_modules/@types/react-router-dom": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/@types/react-router-dom/-/react-router-dom-5.3.3.tgz", + "integrity": "sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/history": "^4.7.11", + "@types/react": "*", + "@types/react-router": "*" + } + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.31.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.31.0.tgz", @@ -3908,6 +3949,38 @@ } } }, + "node_modules/react-router": { + "version": "6.30.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.0.tgz", + "integrity": "sha512-D3X8FyH9nBcTSHGdEKurK7r8OYE1kKFn3d/CF+CoxbSHkxU7o37+Uh7eAHRXr6k2tSExXYO++07PeXJtA/dEhQ==", + "license": "MIT", + "dependencies": { + "@remix-run/router": "1.23.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.30.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.0.tgz", + "integrity": "sha512-x30B78HV5tFk8ex0ITwzC9TTZMua4jGyA9IUlH1JLQYQTFyxr/ZxwOJq7evg1JX1qGVUcvhsmQSKdPncQrjTgA==", + "license": "MIT", + "dependencies": { + "@remix-run/router": "1.23.0", + "react-router": "6.30.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/react-style-singleton": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.3.tgz", diff --git a/client/package.json b/client/package.json index e5281a1..ee981eb 100644 --- a/client/package.json +++ b/client/package.json @@ -14,7 +14,8 @@ "howler": "^2.2.4", "lucide-react": "^0.503.0", "react": "^19.1.0", - "react-dom": "^19.0.0" + "react-dom": "^19.0.0", + "react-router-dom": "^6.30.0" }, "devDependencies": { "@eslint/js": "^9.21.0", @@ -22,6 +23,7 @@ "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", "@types/react-howler": "^5.2.3", + "@types/react-router-dom": "^5.3.3", "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.21", "eslint": "^9.21.0", diff --git a/client/src/App.tsx b/client/src/App.tsx index a3d0943..0fed41c 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -2,8 +2,8 @@ import React from 'react'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import { Login } from './components/screens/Login'; import GameMap from './components/screens/GameMap'; -import GameOver from './components/screens/GameOver'; -import Victory from './components/screens/Victory'; +// import GameOver from './components/screens/GameOver'; +// import Victory from './components/screens/Victory'; import Signup from './components/screens/Signup'; import './styles/codezilla.css'; @@ -14,9 +14,9 @@ const App: React.FC = () => { } /> } /> - } /> + {/* } /> */} } /> - } /> + {/* } /> */} diff --git a/client/src/components/screens/GameMap.tsx b/client/src/components/screens/GameMap.tsx index 99c478e..c17ddd1 100644 --- a/client/src/components/screens/GameMap.tsx +++ b/client/src/components/screens/GameMap.tsx @@ -1,48 +1,86 @@ -// MapScreen with clickable monster nodes -//IMPORT LIBRARIES +// src/components/screens/GameMap.tsx + +// IMPORT LIBRARIES import React from 'react'; import { useNavigate } from 'react-router-dom'; +import Minion from './Minions'; +import "../../styles/codezilla.css"; -// ARRAY OF MINIONS: ID,POSITION ON SCREEN??, IMG SRC, QUESTION ID? (TALK 2 BACKEND TEAM, ON HOW TO USE W/ AI) -const minions = [ - { id: 1, name: 'Nullbyte', x: '10%', y: '20%', image: '/clients/minions/nullbyte3.png', questionId: 0 }, - { id: 2, name: 'Typerrorasaurus', x: '30%', y: '50%', image: '/clients/minions/typerrorasaurus.png', questionId: 1 }, - { id: 3, name: 'Dbug', x: '30%', y: '50%', image: '/clients/minions/Dbug2a.png', questionId: 1 }, - { id: 4, name: 'Pie-thon', x: '30%', y: '50%', image: '/clients/minions/pie-thon.png', questionId: 1 }, - { id: 5, name: 'Codezilla', x: '30%', y: '50%', image: '/clients/minions/codezilla2.png', questionId: 1 }, - -]; -// CREATE FUNCTIONAL COMPONENT MAPSCREEN, USENAVIGATE() -// CREATE FUNCTION CALLED GOTOQUESTIONS -// INSIDE GOTOQUESTIONS: IDENTIFY EACH QUESTION WITH A MINION -// ADD BACKGROUND IMG SRC "/clients/backgrounds/codezilla_bkgd.png" -// CREATE A CONTAINER QUIZ-CONTAINER -// INSIDE CONTAINER A MAP THAT HAS CLICKABLE MINIONS ON NODES CONNECTED WITH LINES -// POPUP QUESTION SCREEN FOR EACH QUESTION -// WHEN CLICKED IT TAKES TO GOTOQUESTION ASSCOIATED WITH EACH MINION -// THEN EITHR AUTO MATICALLY GOES TO THE NEXT MINION QUESTIONS OR TAKES BACK TO MAP HANDLERESTART? -// EXPORT TO MAPSCREEN - -const MapScreen: React.FC = () => { +const GameMap: React.FC = () => { const navigate = useNavigate(); - const goToQuestion = (id: number) => { - navigate(`/quiz/${id}`); + const minions = [ + { + id: '1', + x: 100, + y: 150, + image: '/minions/nullbyte3a.png', + name: 'Nullbyte', + questionId: 'q1', + }, + { + id: '2', + x: 250, + y: 200, + image: '/minions/dbug2a.png', + name: 'Dbug', + questionId: 'q2', + }, + { + id: '3', + x: 400, + y: 250, + image: '/minions/typerrorus.png', + name: 'Typerrorasaurus', + questionId: 'q3', + }, + { + id: '4', + x: 550, + y: 300, + image: '/minions/monster-left.png', + name: 'Pie-Thon', + questionId: 'q4', + }, + { + id: '5', + x: 700, + y: 350, + image: '/minions/codezilla2.png', + name: 'Codezilla', + questionId: 'q5', + }, + ]; + + const goToQuestion = (questionId: string) => { + console.log('Go to question', questionId); + navigate(`/question/${questionId}`); }; return ( -
+
+ {/* Background image */} + rainy cityscape + + {/* Minions */} {minions.map((minion) => ( -
goToQuestion(minion.questionId)} - > - {minion.name} -
+ id={minion.id} + x={minion.x} + y={minion.y} + image={minion.image} + name={minion.name} + questionId={minion.questionId} + goToQuestion={goToQuestion} + /> ))}
); }; -export default MapScreen; +export default GameMap; diff --git a/client/src/components/screens/GameOver.tsx b/client/src/components/screens/GameOver.tsx index 0a392c5..c601bd2 100644 --- a/client/src/components/screens/GameOver.tsx +++ b/client/src/components/screens/GameOver.tsx @@ -1,11 +1,48 @@ -// GameOver you lost screen :( -// TODO: IMPORT LIBRARIES: REACT, REACT-ROUTER-DOM -// TODO: FUNCTIONAL GAMEOVER COMPONENT -// TODO: USENAVIGATE() -// TODO: ADD IMG SRC "/clients/backgrounds/codezilla_bkgd.png" -// TODO: NAVIGATE USERS BACK TO THE MAP -// TODO: CREATE A CONTAINER GAMEOVER-CONTAINER W/ A GAME OVER HEADING -// TODO: CREATE A GAME OVER MESSAGE -// TODO: CREATE A RESTRT HANDLE -// TODO: EXPORT DEFAULT GAMEOVER; +import './codezilla.css'; +const GameOverPage = ({ + backgroundUrl = '/assets/background.jpg', + logoUrl = '/assets/codezilla-logo.png', + avatarUrl = '/assets/player-avatar.png', + codezillaUrl = '/assets/codezilla.png', +}) => { + return ( +
+ Codezilla Logo + +
+

Game Over!

+ +
+ Player Avatar + Codezilla +
+ +

+ You were defeated by Codezilla! +

+ +

+ Try again to become a code master +

+
+
+ ); +}; + +export default GameOverPage; diff --git a/client/src/components/screens/Login.tsx b/client/src/components/screens/Login.tsx index 29ca092..d9f7059 100644 --- a/client/src/components/screens/Login.tsx +++ b/client/src/components/screens/Login.tsx @@ -1,20 +1,20 @@ // src/components/Login.tsx import React from 'react'; -import '../styles/codezilla.css'; +import "../../styles/codezilla.css"; import { useNavigate } from 'react-router-dom'; export const Login: React.FC = () => { const navigate = useNavigate(); const handleLogin = () => { - navigate('/map'); + navigate('/signup'); }; return (
rainy cityscape @@ -24,7 +24,7 @@ export const Login: React.FC = () => {

Not a player yet?

- +
diff --git a/client/src/components/screens/Minions.tsx b/client/src/components/screens/Minions.tsx index e69de29..617710b 100644 --- a/client/src/components/screens/Minions.tsx +++ b/client/src/components/screens/Minions.tsx @@ -0,0 +1,27 @@ +// src/components/Minion.tsx + +import React from 'react'; + +interface MinionProps { + id: string; + x: number; + y: number; + image: string; + name: string; + questionId: string; + goToQuestion: (questionId: string) => void; +} + +const Minion: React.FC = ({ id, x, y, image, name, questionId, goToQuestion }) => { + return ( +
goToQuestion(questionId)} + > + {name} +
+ ); +}; + +export default Minion; diff --git a/client/src/components/screens/Questions.tsx b/client/src/components/screens/Questions.tsx new file mode 100644 index 0000000..e69de29 diff --git a/client/src/components/screens/Signup.tsx b/client/src/components/screens/Signup.tsx index c3fd5ba..415ed11 100644 --- a/client/src/components/screens/Signup.tsx +++ b/client/src/components/screens/Signup.tsx @@ -2,15 +2,14 @@ /*CREATE IMPORTS */ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; -import '../styles/codezilla.css'; +import "../../styles/codezilla.css"; const avatarList = [ - '/client/avatars/carmen.png', - '/client/avatars/jacquilyn.png', - '/client/avatars/trevor.png', - '/client/avatars/michael.png', - '/client/avatars/shawna.png', - + '/avatars/carmen.png', + '/avatars/jacquilyn.png', + '/avatars/trevor.png', + '/avatars/michael.png', + '/avatars/shawna.png', ]; const SignUp: React.FC = () => { @@ -28,7 +27,7 @@ const SignUp: React.FC = () => { return (
Background diff --git a/client/src/components/screens/Victory.tsx b/client/src/components/screens/Victory.tsx index 1f00041..771bec6 100644 --- a/client/src/components/screens/Victory.tsx +++ b/client/src/components/screens/Victory.tsx @@ -1,12 +1,46 @@ -// Victory screen with return to map link -// TODO: IMPORT LIBRARIES: REACT, REACT-ROUTER-DOM -// TODO:CR8 FUNCTIONAL VICTORY COMPONENT -// TODO: W/I VICTORY COMPONENT USENAVIGATE() -// TODO: ADD IMG SRC "/clients/backgrounds/codezilla_bkgd.png" -// TODO: NAVIGATE BACK TO THE MAP -// TODO: CREAT A CONTAINER VICTORY-CONTAINER -// TODO: CREATE "VICTORY" HEADER -// TODO: CREATE A VICTORY CONGRATULATORY MESSAGE -// TODO: CREATE A PLAY AGAIN BUTTON -// TODO: EXPORT DEFAULT VICTORY +import './codezilla.css'; + +export default function VictoryPage({ + backgroundUrl = '/assets/background.jpg', + logoUrl = '/assets/codezilla-logo.png', + avatarUrl = '/assets/player-avatar.png', + confettiUrl = '/assets/confetti.png', +}) { + return ( +
+ Codezilla Logo + +
+ {/* Confetti overlay */} +
+ +

Congratulations!

+ + Player Avatar + +

+ You defeated Codezilla! +

+ +

+ you are a coding master! +

+
+
+ ); +} diff --git a/client/src/styles/codezilla.css b/client/src/styles/codezilla.css index c5fb0d1..a72e919 100644 --- a/client/src/styles/codezilla.css +++ b/client/src/styles/codezilla.css @@ -1,21 +1,30 @@ /* BACKGROUND */ -.body { +/* .body { background-image: url('/clients/backgrounds/codezilla_bkgd.png'); background-size: cover; background-position: center; background-repeat: no-repeat; - height: 100vh; + height: 100vh; */ - } - /* .background-image { + /* } */ + .background-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; - } */ + } + .login-wrapper{ + height: 100vh; + width: 100vw; + display:flex; + align-items: center; + justify-content: center; + position: relative; + overflow:hidden; + } /* SIGNUP */ .signup-button { @@ -27,6 +36,26 @@ margin-top: 20px; } + .avatar-grid { + display:flex; + flex-wrap: wrap; + justify-content: center; + gap: 1.5rem; + margin: 2 rem 0; + width: 100%; + } + + .avatar-option{ + width: 150px; + height: 150px; + object-fit: cover; + border-radius: 50%; + cursor: pointer; + transition: transform 0.3s ease, box-shadow 0.3s ease; + border: 2px solid transparent; + } + + .avata /* QUIZ CONTAINER */ .quiz-container { @@ -41,8 +70,9 @@ .question-box { position: absolute; top: 50%; - left: 50%; - width: 90%; + left: 50%; + height: 80%; + width: 80%; max-width: 600px; transform: translate(-50%, -50%); background: rgba(0, 0, 50, 0.85); @@ -72,4 +102,152 @@ z-index: 10; } - \ No newline at end of file + /* Game Over Page Styling */ + /* Full-screen rainy night background */ +.game-over-page { + width: 100vw; + height: 100vh; + background-size: cover; + background-position: center; + display: flex; + justify-content: center; + align-items: center; + position: relative; + font-family: sans-serif; +} + +/* Logo in top-left corner */ +.game-over-logo { + position: absolute; + top: 20px; + left: 20px; + width: 160px; /* adjust as needed */ +} + +/* The dark rounded panel */ +.game-over-container { + background: rgba(0, 0, 30, 0.9); + border-radius: 40px; + padding: 40px 60px; + box-shadow: 0 0 30px rgba(255, 0, 0, 0.5); + text-align: center; + max-width: 800px; + width: calc(100% - 80px); +} + +/* “Game Over!” */ +.game-over-title { + color: #e00; + font-size: 4rem; + margin: 0; +} + +/* Avatars row */ +.game-over-images { + display: flex; + justify-content: center; + align-items: center; + gap: 2rem; + margin: 2.5rem 0; +} + +.player-avatar, +.codezilla-avatar { + width: 120px; /* adjust size */ + height: auto; +} + +/* “You were defeated…” */ +.game-over-subtitle { + color: #e00; + font-size: 2rem; + margin: 0.5rem 0 1.5rem; +} + +/* “try again…” */ +.game-over-cta { + color: #fff; + font-size: 1.25rem; + margin: 0; +} + +/* Victory Page Styling */ +/* Full-screen rainy night background */ +.victory-page { + width: 100vw; + height: 100vh; + background-size: cover; + background-position: center; + display: flex; + justify-content: center; + align-items: center; + position: relative; + font-family: sans-serif; +} + +/* Logo in top-left corner */ +.victory-logo { + position: absolute; + top: 20px; + left: 20px; + width: 160px; +} + +/* Dark rounded panel container */ +.victory-container { + position: relative; + background: rgba(0, 0, 30, 0.9); + border-radius: 40px; + padding: 40px 60px; + box-shadow: 0 0 30px rgba(255, 255, 255, 0.3); + text-align: center; + max-width: 800px; + width: calc(100% - 80px); + overflow: hidden; +} + +/* Confetti overlay inside the panel */ +.victory-confetti { + position: absolute; + inset: 0; + background-size: cover; + background-position: center; + opacity: 0.8; + pointer-events: none; +} + +/* “Congratulations!” */ +.victory-title { + color: #fff; + font-size: 3.5rem; + margin: 0; + position: relative; + z-index: 1; +} + +/* Player avatar */ +.victory-avatar { + width: 120px; + height: auto; + margin: 2rem 0; + position: relative; + z-index: 1; +} + +/* “You defeated Codezilla!” */ +.victory-subtitle { + color: #fff; + font-size: 2rem; + margin: 0.5rem 0 1rem; + position: relative; + z-index: 1; +} + +/* “you are a coding master!” */ +.victory-cta { + color: #fff; + font-size: 1.25rem; + margin: 0; + position: relative; + z-index: 1; +} diff --git a/package-lock.json b/package-lock.json index bc88d66..f691d2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,14 +14,23 @@ "bcrypt": "^5.1.1", "cors": "^2.8.5", "dotenv": "^16.5.0", +<<<<<<< HEAD + "express": "^5.1.0", + "mongoose": "^8.13.3", +======= "express": "^4.17.1", +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "openai": "^4.95.1", "react": "^19.1.0" }, "devDependencies": { +<<<<<<< HEAD + "@types/express": "^5.0.1", +======= "@types/bcrypt": "^5.0.2", "@types/express": "^4.17.17", "@types/jsonwebtoken": "^9.0.9", +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "@types/mongoose": "^5.11.96", "@types/node": "^22.14.1", "concurrently": "^9.1.2", @@ -367,6 +376,8 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, +<<<<<<< HEAD +======= "node_modules/@mapbox/node-pre-gyp": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", @@ -387,16 +398,22 @@ "node-pre-gyp": "bin/node-pre-gyp" } }, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "node_modules/@mongodb-js/saslprep": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.2.2.tgz", "integrity": "sha512-EB0O3SCSNRUFk66iRCpI+cXzIjdswfCs7F6nOC3RAGJ7xr5YhaicvsRwJ9eyzYvYRlCSDUO/c7g4yNulxKC1WA==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "dependencies": { "sparse-bitfield": "^3.0.3" } }, +<<<<<<< HEAD +======= "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -461,6 +478,7 @@ "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==", "license": "BSD-3-Clause" }, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -606,6 +624,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/mongoose": { + "version": "5.11.96", + "resolved": "https://registry.npmjs.org/@types/mongoose/-/mongoose-5.11.96.tgz", + "integrity": "sha512-keiY22ljJtXyM7osgScmZOHV6eL5VFUD5tQumlu+hjS++HND5nM8jNEdj5CSWfKIJpVwQfPuwQ2SfBqUnCAVRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mongoose": "*" + } + }, "node_modules/@types/node": { "version": "22.15.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.2.tgz", @@ -662,25 +690,34 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT" }, "node_modules/@types/whatwg-url": { "version": "11.0.5", "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "dependencies": { "@types/webidl-conversions": "*" } }, +<<<<<<< HEAD +======= "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "license": "ISC" }, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -1154,7 +1191,10 @@ "version": "6.10.3", "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.3.tgz", "integrity": "sha512-MTxGsqgYTwfshYWTRdmZRC+M7FnG1b4y7RO7p2k3X24Wq0yv1m77Wsj0BzlPzd/IowgESfsruQCUToa7vbOpPQ==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "Apache-2.0", "engines": { "node": ">=16.20.1" @@ -2167,6 +2207,15 @@ "node": ">=12.0.0" } }, + "node_modules/kareem": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.6.3.tgz", + "integrity": "sha512-C3iHfuGUXK2u8/ipq9LfjFfXFxAZMQJJq7vLS45r3D9Y2xQ/m4S8zaR4zMLFWh9AsNPXmcFfUDhTEO8UIC/V6Q==", + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -2264,7 +2313,10 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT" }, "node_modules/merge-descriptors": { @@ -2327,6 +2379,12 @@ "node": "*" } }, +<<<<<<< HEAD + "node_modules/mongodb": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.15.0.tgz", + "integrity": "sha512-ifBhQ0rRzHDzqp9jAQP6OwHSH7dbYIQjD3SbJs9YYk9AikKEettW/9s/tbSFDTpXcRbF+u1aLrhHxDFaYtZpFQ==", +======= "node_modules/minipass": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", @@ -2378,6 +2436,7 @@ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.16.0.tgz", "integrity": "sha512-D1PNcdT0y4Grhou5Zi/qgipZOYeWrhLEpk33n3nm6LGtz61jvO88WlrWCK/bigMjpnOdAUKKQwsGIl0NtWMyYw==", "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "Apache-2.0", "dependencies": { "@mongodb-js/saslprep": "^1.1.9", @@ -2424,7 +2483,10 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "Apache-2.0", "dependencies": { "@types/whatwg-url": "^11.0.2", @@ -2435,7 +2497,10 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "dependencies": { "punycode": "^2.3.1" @@ -2448,7 +2513,10 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "BSD-2-Clause", "engines": { "node": ">=12" @@ -2458,7 +2526,10 @@ "version": "14.2.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "dependencies": { "tr46": "^5.1.0", @@ -2469,15 +2540,25 @@ } }, "node_modules/mongoose": { +<<<<<<< HEAD + "version": "8.13.3", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.13.3.tgz", + "integrity": "sha512-85S6AOABJcgn77ZKFZKOQkWID69vvtv0YFOk+mMOUrq/7+ziIyybWGZSGQRxN9M41Ehe6a9ug41nV13uJFB9Pw==", +======= "version": "8.14.0", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.14.0.tgz", "integrity": "sha512-IxDxIUu42apE7oEknJK535xkQ6Gd7GKx/gNrNHY+vP4+ucVU2TOCWjVVW14Vc79y9DEEElzHDlTOuVNM8glUFA==", "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "dependencies": { "bson": "^6.10.3", "kareem": "2.6.3", +<<<<<<< HEAD + "mongodb": "~6.15.0", +======= "mongodb": "~6.16.0", +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "mpath": "0.9.0", "mquery": "5.0.0", "ms": "2.1.3", @@ -2495,7 +2576,10 @@ "version": "0.9.0", "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "engines": { "node": ">=4.0.0" @@ -2505,7 +2589,10 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "dependencies": { "debug": "4.x" @@ -2807,7 +2894,10 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", +<<<<<<< HEAD +======= "dev": true, +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "license": "MIT", "engines": { "node": ">=6" @@ -3123,6 +3213,193 @@ ], "license": "MIT" }, +<<<<<<< HEAD + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/shell-quote": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.2.tgz", + "integrity": "sha512-AzqKpGKjrj7EM6rKVQEPpB288oCfnrEIuyoT9cyF4nmGa7V8Zk6f7RRqYisX8X9m+Q7bd632aZW4ky7EhbQztA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/sift": { + "version": "17.1.3", + "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz", + "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==", + "license": "MIT" + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "license": "MIT", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, +======= +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", diff --git a/package.json b/package.json index d4d6816..eabd66e 100644 --- a/package.json +++ b/package.json @@ -29,14 +29,23 @@ "bcrypt": "^5.1.1", "cors": "^2.8.5", "dotenv": "^16.5.0", +<<<<<<< HEAD + "express": "^5.1.0", + "mongoose": "^8.13.3", +======= "express": "^4.17.1", +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "openai": "^4.95.1", "react": "^19.1.0" }, "devDependencies": { +<<<<<<< HEAD + "@types/express": "^5.0.1", +======= "@types/bcrypt": "^5.0.2", "@types/express": "^4.17.17", "@types/jsonwebtoken": "^9.0.9", +>>>>>>> f02311985330e2744b6b35806e278a31f6acc830 "@types/mongoose": "^5.11.96", "@types/node": "^22.14.1", "concurrently": "^9.1.2", diff --git a/server/src/config/connections.ts b/server/src/config/connections.ts index e69de29..41ad3cc 100644 --- a/server/src/config/connections.ts +++ b/server/src/config/connections.ts @@ -0,0 +1,19 @@ +import dotenv from 'dotenv'; +dotenv.config(); + +import mongoose from 'mongoose'; + +const MONGODB_URI = process.env.MONGODB_URI || ''; + +const db = async (): Promise => { + try { + await mongoose.connect(MONGODB_URI); + console.log('Database connected.'); + return mongoose.connection; + } catch (error) { + console.error('Database connection error:', error); + throw new Error('Database connection failed.'); + } +}; + +export default db;