Compare commits
139 Commits
Author | SHA1 | Date | |
---|---|---|---|
af6f9cd131 | |||
fd916a8d63 | |||
f65fbd70aa | |||
|
1c704cb606 | ||
|
eee941ffcc | ||
|
0d5e9351ab | ||
|
a01b9a0f48 | ||
88c0de660e | |||
5948ed561c | |||
753669c0af | |||
90040f9049 | |||
9c4696b797 | |||
5d2528da5f | |||
a0a347e0c2 | |||
e7d689cdde | |||
f9fef07b9a | |||
eb4e4b2444 | |||
2e8ba9c5b1 | |||
92289c87b3 | |||
525c2b6d5a | |||
0e218750f8 | |||
fa8552d488 | |||
ef66904c60 | |||
b575fc7fde | |||
|
da3dc6fdad | ||
|
26abdd6aa5 | ||
f98b003808 | |||
|
468f1cfa31 | ||
6856cd3b71 | |||
|
7c8e37aea8 | ||
c738e8044a | |||
499cbf3409 | |||
|
54b01f81c5 | ||
|
24f085e17a | ||
fdbd372430 | |||
30894c59c4 | |||
34bbfb3d5d | |||
|
9f1df7f7f4 | ||
|
f6a8cebbec | ||
|
5a49a1e4f8 | ||
|
096eadce13 | ||
|
1fd60e39d4 | ||
|
332e4e94d8 | ||
|
d86570996e | ||
|
c691b710b7 | ||
|
6c79a4e9b3 | ||
|
559973de5a | ||
6cd421ba01 | |||
0a2d513d3c | |||
bb911173ec | |||
911e5a2c79 | |||
999f884694 | |||
|
8f46ad77b8 | ||
c4c4031e4c | |||
5c393cb73d | |||
|
94d3369d4e | ||
4aced5ed2d | |||
b2c4178482 | |||
8a7fbd074b | |||
e4db4ab403 | |||
67c1b9e821 | |||
|
fe3039b4f3 | ||
|
d5a11d214c | ||
|
2877fc3fd7 | ||
|
879cbac17f | ||
0b42dde699 | |||
b447dcd985 | |||
98ea02b56c | |||
8f96a2e5c9 | |||
a7885ecf53 | |||
6cedd74473 | |||
d17fe1d912 | |||
c1589b9758 | |||
|
859147ea3d | ||
|
2831e2a39e | ||
|
f38867598e | ||
f8abf7cd48 | |||
8464c4debc | |||
dd6dc787e9 | |||
0f480af1f0 | |||
7dd862e134 | |||
|
489387ec9f | ||
|
900f98615d | ||
|
3124f05544 | ||
ba566040b1 | |||
c345cea888 | |||
8a3de628a6 | |||
19bbca36ca | |||
8231f9db67 | |||
c6b15074fb | |||
22c5a8a83d | |||
59cb5e27f8 | |||
30e921f0ea | |||
98956a4c5d | |||
22291958d1 | |||
abf238b1fb | |||
2fed0619a0 | |||
eea74dab09 | |||
8492c82e4f | |||
1e62ba70d1 | |||
fba8212aeb | |||
5c7e26a1a9 | |||
|
df2071439d | ||
|
e773477fb0 | ||
|
196c36444d | ||
6a9e677043 | |||
|
329cc7c74f | ||
|
30c407563d | ||
|
4f338a2005 | ||
|
b717c94e4e | ||
caed17bc8e | |||
|
c7cd9481f3 | ||
d402a67266 | |||
|
340acfa2ed | ||
c1fe10ddc8 | |||
|
532b5d3876 | ||
38d9267bff | |||
|
528cb80c1f | ||
|
a1ed8d14fa | ||
|
641eca074f | ||
|
ae1c05c944 | ||
|
7ea36e01e5 | ||
|
9c583ce5e0 | ||
|
61c138f5c3 | ||
|
d9b0c827c8 | ||
|
e1befed115 | ||
|
0a1323da8a | ||
|
7e17e1c9e9 | ||
|
ab80301f31 | ||
|
c332594b40 | ||
|
fa8c2e7cf9 | ||
|
4c75dc2c75 | ||
ffe8dad9ff | |||
1e0f79387a | |||
|
1b86e6260f | ||
|
e4608b1982 | ||
|
cce32d2267 | ||
|
75725c2124 | ||
|
489cffca6d |
2
.gitignore
vendored
@ -347,3 +347,5 @@ sketch
|
||||
|
||||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
||||
|
||||
server/public/
|
||||
server/mongo-data/
|
||||
|
32
README.md
@ -1,3 +1,31 @@
|
||||
# Sports Matcher
|
||||
# team58
|
||||
|
||||
Sports Matcher is an application that allows users to connect with other athletes, schedule sports meets, and rent sports equipment!
|
||||
|
||||
**Built Using**
|
||||
|
||||
It is built using the React framework and React Bootstrap library. It uses MongoDB for the database, Express for the server, and Axios for requests.
|
||||
|
||||
**Instructions**
|
||||
|
||||
To use Sports Matcher, please go to https://hidden-bayou-86321.herokuapp.com
|
||||
|
||||
From here you can Sign In or Sign Up.
|
||||
|
||||
Signing in as 'admin' will take you to the admin page. You will be able to see a list of current matches, users and suspended users. You will need to click the appropriate button for the correct table to appear.
|
||||
|
||||
Every page has a navbar at the top. There is a chat and profile icon. Clicking on the chat icon will take you to the chat page. From the profile icon you can sign out.
|
||||
|
||||
|
||||
|
||||
**Functionality**
|
||||
|
||||
Our app has a fully functioning backend which supports the CRUD functionality for the following entites
|
||||
1. We have a User entity which has the following attributes: Name, Email and Password, Sports and levels, Griends, Auth level, and suspended status
|
||||
2. We have a Match which supports the following attributes: Players, Date, Sport and skill, and Location
|
||||
|
||||
We also support searching the database for the above entites.
|
||||
1. Matches can be searched for. They can be sorted and filtered based on location, friends, skill level and date.
|
||||
2. Users can also be searched for
|
||||
|
||||
|
||||
A CSC309 Project.
|
@ -1,11 +0,0 @@
|
||||
const prod = {
|
||||
env: "production",
|
||||
api_host: ""
|
||||
};
|
||||
const dev = {
|
||||
env: "development",
|
||||
api_host: "http://localhost:5000", // web server localhost port
|
||||
};
|
||||
|
||||
// export the appropriate environment
|
||||
export default process.env.NODE_ENV === "production" ? prod : dev;
|
436
client/package-lock.json
generated
@ -11,8 +11,12 @@
|
||||
"@testing-library/jest-dom": "^5.16.3",
|
||||
"@testing-library/react": "^12.1.4",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"axios": "^0.26.1",
|
||||
"bootstrap": "^5.1.3",
|
||||
"react": "^17.0.2",
|
||||
"react-bootstrap": "^2.2.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "^6.2.2",
|
||||
"react-scripts": "5.0.0",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
@ -2815,6 +2819,57 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@popperjs/core": {
|
||||
"version": "2.11.4",
|
||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.4.tgz",
|
||||
"integrity": "sha512-q/ytXxO5NKvyT37pmisQAItCFqA7FD/vNb8dgaJy3/630Fsc+Mz9/9f2SziBoIZ30TJooXyTwZmhi1zjXmObYg==",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/popperjs"
|
||||
}
|
||||
},
|
||||
"node_modules/@react-aria/ssr": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.1.2.tgz",
|
||||
"integrity": "sha512-amXY11ImpokvkTMeKRHjsSsG7v1yzzs6yeqArCyBIk60J3Yhgxwx9Cah+Uu/804ATFwqzN22AXIo7SdtIaMP+g==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0-rc.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@restart/hooks": {
|
||||
"version": "0.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@restart/hooks/-/hooks-0.4.5.tgz",
|
||||
"integrity": "sha512-tLGtY0aHeIfT7aPwUkvQuhIy3+q3w4iqmUzFLPlOAf/vNUacLaBt1j/S//jv/dQhenRh8jvswyMojCwmLvJw8A==",
|
||||
"dependencies": {
|
||||
"dequal": "^2.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@restart/ui": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@restart/ui/-/ui-1.2.0.tgz",
|
||||
"integrity": "sha512-oIh2t3tG8drZtZ9SlaV5CY6wGsUViHk8ZajjhcI+74IQHyWy+AnxDv8rJR5wVgsgcgrPBUvGNkC1AEdcGNPaLQ==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.16",
|
||||
"@popperjs/core": "^2.10.1",
|
||||
"@react-aria/ssr": "^3.0.1",
|
||||
"@restart/hooks": "^0.4.0",
|
||||
"@types/warning": "^3.0.0",
|
||||
"dequal": "^2.0.2",
|
||||
"dom-helpers": "^5.2.0",
|
||||
"uncontrollable": "^7.2.1",
|
||||
"warning": "^4.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.14.0",
|
||||
"react-dom": ">=16.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-babel": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
|
||||
@ -3497,6 +3552,11 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/invariant": {
|
||||
"version": "2.2.35",
|
||||
"resolved": "https://registry.npmjs.org/@types/invariant/-/invariant-2.2.35.tgz",
|
||||
"integrity": "sha512-DxX1V9P8zdJPYQat1gHyY0xj3efl8gnMVjiM9iCY6y27lj+PoQWkgjt8jDqmovPqULkKVpKRg8J36iQiA+EtEg=="
|
||||
},
|
||||
"node_modules/@types/istanbul-lib-coverage": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
|
||||
@ -3595,6 +3655,14 @@
|
||||
"@types/react": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/react-transition-group": {
|
||||
"version": "4.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.4.tgz",
|
||||
"integrity": "sha512-7gAPz7anVK5xzbeQW9wFBDg7G++aPLAFY0QaSMOou9rJZpbuI58WAuJrgu+qR92l61grlnCUe7AFX8KGahAgug==",
|
||||
"dependencies": {
|
||||
"@types/react": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
|
||||
@ -3656,6 +3724,11 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz",
|
||||
"integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg=="
|
||||
},
|
||||
"node_modules/@types/warning": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz",
|
||||
"integrity": "sha1-DSUBJorY+ZYrdA04fEZU9fjiPlI="
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
|
||||
@ -4453,6 +4526,14 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.26.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
|
||||
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.8"
|
||||
}
|
||||
},
|
||||
"node_modules/axobject-query": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
|
||||
@ -4861,6 +4942,18 @@
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||
},
|
||||
"node_modules/bootstrap": {
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz",
|
||||
"integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/bootstrap"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@popperjs/core": "^2.10.2"
|
||||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
@ -5122,6 +5215,11 @@
|
||||
"resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz",
|
||||
"integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA=="
|
||||
},
|
||||
"node_modules/classnames": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
|
||||
"integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
|
||||
},
|
||||
"node_modules/clean-css": {
|
||||
"version": "5.2.4",
|
||||
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.4.tgz",
|
||||
@ -6002,6 +6100,14 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/dequal": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz",
|
||||
"integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/destroy": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
@ -6140,6 +6246,15 @@
|
||||
"utila": "~0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/dom-helpers": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",
|
||||
"integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"csstype": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/dom-serializer": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
|
||||
@ -7969,6 +8084,14 @@
|
||||
"he": "bin/he"
|
||||
}
|
||||
},
|
||||
"node_modules/history": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz",
|
||||
"integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.6"
|
||||
}
|
||||
},
|
||||
"node_modules/hoopy": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz",
|
||||
@ -8329,6 +8452,14 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/invariant": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
|
||||
"integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ip": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
|
||||
@ -12924,6 +13055,23 @@
|
||||
"react-is": "^16.13.1"
|
||||
}
|
||||
},
|
||||
"node_modules/prop-types-extra": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types-extra/-/prop-types-extra-1.1.1.tgz",
|
||||
"integrity": "sha512-59+AHNnHYCdiC+vMwY52WmvP5dM3QLeoumYuEyceQDi9aEhtwN9zIQ2ZNo25sMyXnbh32h+P1ezDsUpUH3JAew==",
|
||||
"dependencies": {
|
||||
"react-is": "^16.3.2",
|
||||
"warning": "^4.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=0.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prop-types-extra/node_modules/react-is": {
|
||||
"version": "16.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
|
||||
},
|
||||
"node_modules/prop-types/node_modules/react-is": {
|
||||
"version": "16.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||
@ -13097,6 +13245,33 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/react-bootstrap": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-2.2.2.tgz",
|
||||
"integrity": "sha512-zfVGUU14BMZo7KqR1QHXBAqpbWa6bu4S9dZ6O4rd/hDZi1tiNeGkISbuBednb1TxyXrOwpvnvlHNk3OuYQNq6w==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.17.2",
|
||||
"@restart/hooks": "^0.4.5",
|
||||
"@restart/ui": "^1.2.0",
|
||||
"@types/invariant": "^2.2.35",
|
||||
"@types/prop-types": "^15.7.4",
|
||||
"@types/react": ">=16.14.8",
|
||||
"@types/react-transition-group": "^4.4.4",
|
||||
"@types/warning": "^3.0.0",
|
||||
"classnames": "^2.3.1",
|
||||
"dom-helpers": "^5.2.1",
|
||||
"invariant": "^2.2.4",
|
||||
"prop-types": "^15.8.1",
|
||||
"prop-types-extra": "^1.1.0",
|
||||
"react-transition-group": "^4.4.2",
|
||||
"uncontrollable": "^7.2.1",
|
||||
"warning": "^4.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.14.0",
|
||||
"react-dom": ">=16.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-dev-utils": {
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.0.tgz",
|
||||
@ -13237,6 +13412,11 @@
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
|
||||
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
|
||||
},
|
||||
"node_modules/react-lifecycles-compat": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
|
||||
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
|
||||
},
|
||||
"node_modules/react-refresh": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz",
|
||||
@ -13245,6 +13425,30 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.2.tgz",
|
||||
"integrity": "sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==",
|
||||
"dependencies": {
|
||||
"history": "^5.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.8"
|
||||
}
|
||||
},
|
||||
"node_modules/react-router-dom": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.2.tgz",
|
||||
"integrity": "sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==",
|
||||
"dependencies": {
|
||||
"history": "^5.2.0",
|
||||
"react-router": "6.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.8",
|
||||
"react-dom": ">=16.8"
|
||||
}
|
||||
},
|
||||
"node_modules/react-scripts": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.0.tgz",
|
||||
@ -13317,6 +13521,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-transition-group": {
|
||||
"version": "4.4.2",
|
||||
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz",
|
||||
"integrity": "sha512-/RNYfRAMlZwDSr6z4zNKV6xu53/e2BuaBbGhbyYIXTrmgu/bGHzmqOs7mJSJBHy9Ud+ApHx3QjrkKSp1pxvlFg==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.5.5",
|
||||
"dom-helpers": "^5.0.1",
|
||||
"loose-envify": "^1.4.0",
|
||||
"prop-types": "^15.6.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.6.0",
|
||||
"react-dom": ">=16.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
@ -14998,6 +15217,20 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/uncontrollable": {
|
||||
"version": "7.2.1",
|
||||
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.2.1.tgz",
|
||||
"integrity": "sha512-svtcfoTADIB0nT9nltgjujTi7BzVmwjZClOmskKu/E8FW9BXzg9os8OLr4f8Dlnk0rYWJIWr4wv9eKUXiQvQwQ==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.3",
|
||||
"@types/react": ">=16.9.11",
|
||||
"invariant": "^2.2.4",
|
||||
"react-lifecycles-compat": "^3.0.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=15.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
|
||||
@ -15184,6 +15417,14 @@
|
||||
"makeerror": "1.0.12"
|
||||
}
|
||||
},
|
||||
"node_modules/warning": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
|
||||
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/watchpack": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz",
|
||||
@ -18004,6 +18245,43 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@popperjs/core": {
|
||||
"version": "2.11.4",
|
||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.4.tgz",
|
||||
"integrity": "sha512-q/ytXxO5NKvyT37pmisQAItCFqA7FD/vNb8dgaJy3/630Fsc+Mz9/9f2SziBoIZ30TJooXyTwZmhi1zjXmObYg=="
|
||||
},
|
||||
"@react-aria/ssr": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.1.2.tgz",
|
||||
"integrity": "sha512-amXY11ImpokvkTMeKRHjsSsG7v1yzzs6yeqArCyBIk60J3Yhgxwx9Cah+Uu/804ATFwqzN22AXIo7SdtIaMP+g==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.6.2"
|
||||
}
|
||||
},
|
||||
"@restart/hooks": {
|
||||
"version": "0.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@restart/hooks/-/hooks-0.4.5.tgz",
|
||||
"integrity": "sha512-tLGtY0aHeIfT7aPwUkvQuhIy3+q3w4iqmUzFLPlOAf/vNUacLaBt1j/S//jv/dQhenRh8jvswyMojCwmLvJw8A==",
|
||||
"requires": {
|
||||
"dequal": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"@restart/ui": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@restart/ui/-/ui-1.2.0.tgz",
|
||||
"integrity": "sha512-oIh2t3tG8drZtZ9SlaV5CY6wGsUViHk8ZajjhcI+74IQHyWy+AnxDv8rJR5wVgsgcgrPBUvGNkC1AEdcGNPaLQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.13.16",
|
||||
"@popperjs/core": "^2.10.1",
|
||||
"@react-aria/ssr": "^3.0.1",
|
||||
"@restart/hooks": "^0.4.0",
|
||||
"@types/warning": "^3.0.0",
|
||||
"dequal": "^2.0.2",
|
||||
"dom-helpers": "^5.2.0",
|
||||
"uncontrollable": "^7.2.1",
|
||||
"warning": "^4.0.3"
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-babel": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
|
||||
@ -18493,6 +18771,11 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/invariant": {
|
||||
"version": "2.2.35",
|
||||
"resolved": "https://registry.npmjs.org/@types/invariant/-/invariant-2.2.35.tgz",
|
||||
"integrity": "sha512-DxX1V9P8zdJPYQat1gHyY0xj3efl8gnMVjiM9iCY6y27lj+PoQWkgjt8jDqmovPqULkKVpKRg8J36iQiA+EtEg=="
|
||||
},
|
||||
"@types/istanbul-lib-coverage": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
|
||||
@ -18591,6 +18874,14 @@
|
||||
"@types/react": "*"
|
||||
}
|
||||
},
|
||||
"@types/react-transition-group": {
|
||||
"version": "4.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.4.tgz",
|
||||
"integrity": "sha512-7gAPz7anVK5xzbeQW9wFBDg7G++aPLAFY0QaSMOou9rJZpbuI58WAuJrgu+qR92l61grlnCUe7AFX8KGahAgug==",
|
||||
"requires": {
|
||||
"@types/react": "*"
|
||||
}
|
||||
},
|
||||
"@types/resolve": {
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
|
||||
@ -18652,6 +18943,11 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz",
|
||||
"integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg=="
|
||||
},
|
||||
"@types/warning": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz",
|
||||
"integrity": "sha1-DSUBJorY+ZYrdA04fEZU9fjiPlI="
|
||||
},
|
||||
"@types/ws": {
|
||||
"version": "8.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
|
||||
@ -19218,6 +19514,14 @@
|
||||
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.1.tgz",
|
||||
"integrity": "sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.26.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
|
||||
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.14.8"
|
||||
}
|
||||
},
|
||||
"axobject-query": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
|
||||
@ -19542,6 +19846,12 @@
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||
},
|
||||
"bootstrap": {
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz",
|
||||
"integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==",
|
||||
"requires": {}
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
@ -19723,6 +20033,11 @@
|
||||
"resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz",
|
||||
"integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA=="
|
||||
},
|
||||
"classnames": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
|
||||
"integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
|
||||
},
|
||||
"clean-css": {
|
||||
"version": "5.2.4",
|
||||
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.4.tgz",
|
||||
@ -20358,6 +20673,11 @@
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
|
||||
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
|
||||
},
|
||||
"dequal": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz",
|
||||
"integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug=="
|
||||
},
|
||||
"destroy": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
@ -20473,6 +20793,15 @@
|
||||
"utila": "~0.4"
|
||||
}
|
||||
},
|
||||
"dom-helpers": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",
|
||||
"integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"csstype": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"dom-serializer": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
|
||||
@ -21784,6 +22113,14 @@
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
|
||||
},
|
||||
"history": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz",
|
||||
"integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.7.6"
|
||||
}
|
||||
},
|
||||
"hoopy": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz",
|
||||
@ -22048,6 +22385,14 @@
|
||||
"side-channel": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"invariant": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
|
||||
"integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"ip": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
|
||||
@ -25232,6 +25577,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"prop-types-extra": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types-extra/-/prop-types-extra-1.1.1.tgz",
|
||||
"integrity": "sha512-59+AHNnHYCdiC+vMwY52WmvP5dM3QLeoumYuEyceQDi9aEhtwN9zIQ2ZNo25sMyXnbh32h+P1ezDsUpUH3JAew==",
|
||||
"requires": {
|
||||
"react-is": "^16.3.2",
|
||||
"warning": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-is": {
|
||||
"version": "16.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
@ -25347,6 +25708,29 @@
|
||||
"whatwg-fetch": "^3.6.2"
|
||||
}
|
||||
},
|
||||
"react-bootstrap": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-2.2.2.tgz",
|
||||
"integrity": "sha512-zfVGUU14BMZo7KqR1QHXBAqpbWa6bu4S9dZ6O4rd/hDZi1tiNeGkISbuBednb1TxyXrOwpvnvlHNk3OuYQNq6w==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.17.2",
|
||||
"@restart/hooks": "^0.4.5",
|
||||
"@restart/ui": "^1.2.0",
|
||||
"@types/invariant": "^2.2.35",
|
||||
"@types/prop-types": "^15.7.4",
|
||||
"@types/react": ">=16.14.8",
|
||||
"@types/react-transition-group": "^4.4.4",
|
||||
"@types/warning": "^3.0.0",
|
||||
"classnames": "^2.3.1",
|
||||
"dom-helpers": "^5.2.1",
|
||||
"invariant": "^2.2.4",
|
||||
"prop-types": "^15.8.1",
|
||||
"prop-types-extra": "^1.1.0",
|
||||
"react-transition-group": "^4.4.2",
|
||||
"uncontrollable": "^7.2.1",
|
||||
"warning": "^4.0.3"
|
||||
}
|
||||
},
|
||||
"react-dev-utils": {
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.0.tgz",
|
||||
@ -25453,11 +25837,33 @@
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
|
||||
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
|
||||
},
|
||||
"react-lifecycles-compat": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
|
||||
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
|
||||
},
|
||||
"react-refresh": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz",
|
||||
"integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A=="
|
||||
},
|
||||
"react-router": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.2.tgz",
|
||||
"integrity": "sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==",
|
||||
"requires": {
|
||||
"history": "^5.2.0"
|
||||
}
|
||||
},
|
||||
"react-router-dom": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.2.tgz",
|
||||
"integrity": "sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==",
|
||||
"requires": {
|
||||
"history": "^5.2.0",
|
||||
"react-router": "6.2.2"
|
||||
}
|
||||
},
|
||||
"react-scripts": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.0.tgz",
|
||||
@ -25513,6 +25919,17 @@
|
||||
"workbox-webpack-plugin": "^6.4.1"
|
||||
}
|
||||
},
|
||||
"react-transition-group": {
|
||||
"version": "4.4.2",
|
||||
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz",
|
||||
"integrity": "sha512-/RNYfRAMlZwDSr6z4zNKV6xu53/e2BuaBbGhbyYIXTrmgu/bGHzmqOs7mJSJBHy9Ud+ApHx3QjrkKSp1pxvlFg==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.5.5",
|
||||
"dom-helpers": "^5.0.1",
|
||||
"loose-envify": "^1.4.0",
|
||||
"prop-types": "^15.6.2"
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
@ -26754,6 +27171,17 @@
|
||||
"which-boxed-primitive": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"uncontrollable": {
|
||||
"version": "7.2.1",
|
||||
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.2.1.tgz",
|
||||
"integrity": "sha512-svtcfoTADIB0nT9nltgjujTi7BzVmwjZClOmskKu/E8FW9BXzg9os8OLr4f8Dlnk0rYWJIWr4wv9eKUXiQvQwQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.6.3",
|
||||
"@types/react": ">=16.9.11",
|
||||
"invariant": "^2.2.4",
|
||||
"react-lifecycles-compat": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
|
||||
@ -26896,6 +27324,14 @@
|
||||
"makeerror": "1.0.12"
|
||||
}
|
||||
},
|
||||
"warning": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
|
||||
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"watchpack": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz",
|
||||
|
@ -6,13 +6,17 @@
|
||||
"@testing-library/jest-dom": "^5.16.3",
|
||||
"@testing-library/react": "^12.1.4",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"axios": "^0.26.1",
|
||||
"bootstrap": "^5.1.3",
|
||||
"react": "^17.0.2",
|
||||
"react-bootstrap": "^2.2.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "^6.2.2",
|
||||
"react-scripts": "5.0.0",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"start": "NODE_ENV=development API_HOST=http://localhost:5000 react-scripts start",
|
||||
"build": "../scripts/build.py",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
|
@ -1,38 +0,0 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
import logo from "./logo.svg";
|
||||
import "./App.css";
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.js</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
41
client/src/Layout.js
Normal file
@ -0,0 +1,41 @@
|
||||
import "./styles/Layout.css";
|
||||
import "./styles/extra.css";
|
||||
import React from "react";
|
||||
import { NavLink, Route, Routes } from "react-router-dom";
|
||||
import Welcome from "./pages/Welcome";
|
||||
import Navbar from "react-bootstrap/Navbar";
|
||||
import { Container, Nav, NavbarBrand } from "react-bootstrap";
|
||||
import NavbarToggle from "react-bootstrap/esm/NavbarToggle";
|
||||
import NavbarCollapse from "react-bootstrap/esm/NavbarCollapse";
|
||||
export default class Layout extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div id="app">
|
||||
<header>
|
||||
<Navbar bg="light" expand="md">
|
||||
<Container>
|
||||
<NavbarBrand href="/">Sports Matcher</NavbarBrand>
|
||||
<NavbarToggle aria-controls="navigation"></NavbarToggle>
|
||||
<NavbarCollapse id="main-nav">
|
||||
<Nav className="me-auto">
|
||||
<li className="nav-item">
|
||||
<NavLink className="nav-link" to="/" >Home</NavLink>
|
||||
</li>
|
||||
</Nav>
|
||||
</NavbarCollapse>
|
||||
</Container>
|
||||
</Navbar>
|
||||
</header>
|
||||
<main>
|
||||
<Routes>
|
||||
<Route path="/" element={<Welcome></Welcome>}>
|
||||
</Route>
|
||||
</Routes>
|
||||
</main>
|
||||
<footer>
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
36
client/src/components/GameInfoCard.js
Normal file
@ -0,0 +1,36 @@
|
||||
import React from "react";
|
||||
import { Button, Card } from "react-bootstrap";
|
||||
import propTypes from "prop-types";
|
||||
import { grammaticalListString } from "../utils/strings";
|
||||
export default class GameInfoCard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
getParticipants() {
|
||||
let participants = [];
|
||||
this.props.match.registeredUsers.array.forEach(user => {
|
||||
participants.push(user.firstName);
|
||||
});
|
||||
return participants;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Card style={{ width: "20rem" }}>
|
||||
<Card.Body>
|
||||
<Card.Title>{this.props.match.sport}</Card.Title>
|
||||
<Card.Subtitle className="mb-2 text-muted">{this.props.match.sport}</Card.Subtitle>
|
||||
<Card.Text>
|
||||
Join <strong>{grammaticalListString(this.getParticipants(), 4)}</strong> to play a few matches of <strong>{this.props.match.sport}</strong> at <strong>{this.props.match.location}</strong> on <strong>{this.props.match.dateTime.toLocaleDateString("en-US")}</strong>!
|
||||
</Card.Text>
|
||||
<Button variant="primary">Join!</Button>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GameInfoCard.propTypes = {
|
||||
match: propTypes.object,
|
||||
};
|
21
client/src/components/GameInfoCardDisplay.js
Normal file
@ -0,0 +1,21 @@
|
||||
import React from "react";
|
||||
import propTypes from "prop-types";
|
||||
import GameInfoCard from "./GameInfoCard";
|
||||
|
||||
export default class GameInfoCardDisplay extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div className="horizontal-scroller">
|
||||
{this.props.recommendedMatches.map((match) => <GameInfoCard key={match.id} match={match}></GameInfoCard>)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GameInfoCardDisplay.propTypes = {
|
||||
recommendedMatches: propTypes.array,
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import "./index.css";
|
||||
import App from "./App";
|
||||
import Layout from "./Layout";
|
||||
import reportWebVitals from "./reportWebVitals";
|
||||
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import "bootstrap/dist/css/bootstrap.min.css"; // This could be optimized by importing individual css components.
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
<BrowserRouter>
|
||||
<Layout />
|
||||
</BrowserRouter>
|
||||
</React.StrictMode>,
|
||||
document.getElementById("root")
|
||||
);
|
||||
|
28
client/src/pages/Welcome.js
Normal file
@ -0,0 +1,28 @@
|
||||
import React from "react";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
export default class Welcome extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.recentMatchesRequest = apiClient.get("/match/recent/15");
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root">
|
||||
<div className="jumbotron" >
|
||||
<h1>Sports Matcher</h1>
|
||||
<p>The best place to find a local match for a good game of your favourite sport!</p>
|
||||
</div>
|
||||
<div className="text-center p-3 mt-2">
|
||||
<h2>Why?</h2>
|
||||
<p>Because you want to play the sports you love while meeting new friends!</p>
|
||||
{/* TODO: All this text should be expanded on. */}
|
||||
</div>
|
||||
<hr />
|
||||
<div className="p-4">
|
||||
<h2>Available Matches</h2>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
16
client/src/styles/Layout.css
Normal file
@ -0,0 +1,16 @@
|
||||
.page-root,
|
||||
main,
|
||||
#app,
|
||||
#root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
}
|
19
client/src/styles/extra.css
Normal file
@ -0,0 +1,19 @@
|
||||
.jumbotron {
|
||||
width: 100%;
|
||||
padding-left: 1.5rem;
|
||||
padding-right: 1.5rem;
|
||||
padding-top: 12rem;
|
||||
padding-bottom: 1rem;
|
||||
text-align: center;
|
||||
background-size: cover;
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.jumbotron h1 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.horizontal-scroller {
|
||||
overflow-x: scroll;
|
||||
}
|
6
client/src/utils/httpClients.js
Normal file
@ -0,0 +1,6 @@
|
||||
import axios from "axios";
|
||||
|
||||
export const apiClient = axios.create({
|
||||
baseURL: process.env.API_HOST,
|
||||
timeout: 5000,
|
||||
});
|
22
client/src/utils/strings.js
Normal file
@ -0,0 +1,22 @@
|
||||
export function grammaticalListString(items, max) {
|
||||
if (!items) return null;
|
||||
if (max < 1) return "";
|
||||
let built = "";
|
||||
|
||||
let index = 0;
|
||||
items.forEach(item => {
|
||||
if (index > max) {
|
||||
built += "and " + items.length + " more ";
|
||||
return;
|
||||
}
|
||||
built += item;
|
||||
built += ", ";
|
||||
if (index == max - 1) {
|
||||
built += "and ";
|
||||
}
|
||||
|
||||
index += 1;
|
||||
});
|
||||
|
||||
return built;
|
||||
}
|
6
package-lock.json
generated
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "team58",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
|
94
server/controllers/matchController.js
Normal file
@ -0,0 +1,94 @@
|
||||
import express from "express";
|
||||
import { authenticationGuard } from "../middleware/authority.js";
|
||||
import { needDatabase } from "../middleware/database.js";
|
||||
import matchModel from "../schemas/matchModel.js";
|
||||
import sportModel from "../schemas/sportModel.js";
|
||||
import userModel from "../schemas/userModel.js";
|
||||
const MatchController = express.Router();
|
||||
|
||||
MatchController.get("/search/:sport", needDatabase, async (req, res) => {
|
||||
try {
|
||||
let sport = sportModel.findByName(req.params.sport);
|
||||
let query = matchModel.find({ sport: sport._id });
|
||||
query.where("when").gte(Date.now); // We don't want to return any results of matches that have already occurred.
|
||||
if (req.session.userId) query.where("publicity").gte(1).where("friends").in(req.session.userId);
|
||||
if (req.query.within) query.where("location").within({ center: req.query.location.split(","), radius: req.query.within });
|
||||
if (req.query.minDifficulty) query.where("difficulty").gte(req.query.minDifficulty);
|
||||
if (req.query.maxDifficulty) query.where("difficulty").lte(req.query.maxDifficulty);
|
||||
if (req.query.beforeDate) query.where("when").lte(req.query.beforeDate);
|
||||
|
||||
let queryResults = await query;
|
||||
res.send({ queryResults });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
|
||||
let limit = req.params.limit;
|
||||
if (!req.params.limit) limit = 10;
|
||||
if (isNaN(limit)) {
|
||||
res.status(400).send("Limit parameter not a number.");
|
||||
return;
|
||||
}
|
||||
if (limit > 50) {
|
||||
res.status(400).send("Limit greater than maximum limit of 50.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const recent = await matchModel.find().where("publicity").gte(2).limit(limit).sort({ createDate: -1 });
|
||||
res.status(200).send({ recent: recent });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Check and improve error handling.
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: delete, update match.
|
||||
MatchController.post("/", needDatabase, authenticationGuard, async (req, res) => {
|
||||
try {
|
||||
const userId = req.session.userId;
|
||||
const user = await userModel.findById(userId);
|
||||
const match = new matchModel({
|
||||
title: req.body.title,
|
||||
when: req.body.when,
|
||||
public: req.body.public,
|
||||
location: req.body.location,
|
||||
creator: userId,
|
||||
difficulty: req.body.difficulty,
|
||||
sport: await sportModel.findByName(req.body.sport),
|
||||
participants: [user._id]
|
||||
});
|
||||
await match.save();
|
||||
user.createdMatches.push(match._id);
|
||||
user.participatingMatches.push(match._id);
|
||||
await user.save();
|
||||
res.status(201).send(match);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Develop the error handling.
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/:matchId", needDatabase, async (req, res) => {
|
||||
if (!req.params.matchId) {
|
||||
res.status(404).send("Id must be provided to retrieve match");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const match = await matchModel.findById(req.params.matchId);
|
||||
if (match) {
|
||||
res.status(200).send(match);
|
||||
} else {
|
||||
res.status(404).send("Could not find match with ID: " + req.params.matchId);
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Develop the error handling.
|
||||
}
|
||||
});
|
||||
|
||||
export default MatchController;
|
48
server/controllers/sportController.js
Normal file
@ -0,0 +1,48 @@
|
||||
import express from "express";
|
||||
import { authenticationGuard } from "../middleware/authority.js";
|
||||
import { needDatabase } from "../middleware/database.js";
|
||||
import sportModel from "../schemas/sportModel.js";
|
||||
import userModel from "../schemas/userModel.js";
|
||||
|
||||
const SportController = express.Router();
|
||||
|
||||
SportController.post("/", needDatabase, authenticationGuard, async (req, res) => {
|
||||
const user = await userModel.findById(req.session.userId);
|
||||
try {
|
||||
if (user.accessLevel <= 2) {
|
||||
res.status(403).send("Insufficient privileges.");
|
||||
return;
|
||||
}
|
||||
const sport = new sportModel({
|
||||
name: req.body.name,
|
||||
maxPlayers: req.body.maxPlayers,
|
||||
minPlayers: req.body.minPlayers,
|
||||
description: req.body.description
|
||||
});
|
||||
await sport.save();
|
||||
res.status(201).send("Successfully created new sport.");
|
||||
} catch (error) {
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Add proper error checking here.
|
||||
}
|
||||
});
|
||||
|
||||
SportController.get("/:sportId", needDatabase, async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await sportModel.findById(req.params.sportId));
|
||||
} catch (error) {
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Add proper error checking here.
|
||||
}
|
||||
});
|
||||
|
||||
SportController.get("/", needDatabase, async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await sportModel.find());
|
||||
} catch (error) {
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Add proper error checking here.
|
||||
}
|
||||
});
|
||||
|
||||
export default SportController;
|
169
server/controllers/userController.js
Normal file
@ -0,0 +1,169 @@
|
||||
import express from "express";
|
||||
import { authenticationGuard } from "../middleware/authority.js";
|
||||
import { needDatabase } from "../middleware/database.js";
|
||||
import User from "../schemas/userModel.js";
|
||||
const UserController = express.Router();
|
||||
|
||||
UserController.post("/login", needDatabase, async (req, res) => {
|
||||
try {
|
||||
const email = req.body.email;
|
||||
const pwd = req.body.password;
|
||||
const user = await User.credentialsExist(email, pwd);
|
||||
if (!user) {
|
||||
res.sendStatus(401);
|
||||
return;
|
||||
} else {
|
||||
req.session.userId = user._id;
|
||||
req.session.email = user.email;
|
||||
res.status(200).send("Authenticated.");
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.name === "TypeError") {
|
||||
res.status(400).send("Missing required user info.");
|
||||
} else if (error.message === "Credentials do not exist.") {
|
||||
res.status(401).send("Credentials do not exist.");
|
||||
} else {
|
||||
console.error(error);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
res.status(500).send(error.toString());
|
||||
} else {
|
||||
res.status(500).send("Internal server error. This issue has been noted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/logout", authenticationGuard, (req, res) => {
|
||||
req.session.destroy((err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
res.status(500).send(err.toString());
|
||||
} else {
|
||||
res.status(500).send("Internal server error. This issue has been noted.");
|
||||
}
|
||||
res.status(500).send("");
|
||||
} else {
|
||||
res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
UserController.get("/email/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
||||
const curUser = await User.findById(req.session.userId);
|
||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
||||
if (selUser.email.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
||||
res.status(200).send({ email: selUser.email });
|
||||
} else {
|
||||
res.status(401).send("Could not authenticate request.");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/firstName/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
||||
const curUser = await User.findById(req.session.userId);
|
||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
||||
if (selUser.firstName.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
||||
res.status(200).send({ firstName: selUser.firstName });
|
||||
} else {
|
||||
res.status(401).send("Could not authenticate request.");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/lastName/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
||||
const curUser = await User.findById(req.session.userId);
|
||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
||||
if (selUser.lastName.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
||||
res.status(200).send({ email: selUser.lastName });
|
||||
} else {
|
||||
res.status(401).send("Could not authenticate request.");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/phone/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
||||
const curUser = await User.findById(req.session.userId);
|
||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
||||
if (selUser.phone.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
||||
res.status(200).send({ phone: selUser.phone });
|
||||
} else {
|
||||
res.status(401).send("Could not authenticate request.");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/participatingMatches/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
||||
const curUser = await User.findById(req.session.userId);
|
||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
||||
if (selUser.participatingMatches.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
||||
res.status(200).send({ participatingMatches: selUser.participatingMatches });
|
||||
} else {
|
||||
res.status(401).send("Could not authenticate request.");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/joinDate/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
||||
const curUser = await User.findById(req.session.userId);
|
||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
||||
if (curUser._id === selUser._id || curUser.accessLevel > 2) {
|
||||
res.status(200).send({ joinDate: selUser.joinDate });
|
||||
} else {
|
||||
res.status(401).send("Could not authenticate request.");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/createdMatches/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
||||
const curUser = await User.findById(req.session.userId);
|
||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
||||
if (curUser._id === selUser._id || curUser.accessLevel > 2) {
|
||||
res.status(200).send({ createdMatches: selUser.createdMatches });
|
||||
} else {
|
||||
res.status(401).send("Could not authenticate request.");
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Finish update requests using put.
|
||||
|
||||
UserController.post("/", needDatabase, async (req, res) => {
|
||||
try {
|
||||
let createdUser = new User({
|
||||
email: req.body.email,
|
||||
firstName: req.body.firstName,
|
||||
lastName: req.body.lastName,
|
||||
phone: req.body.phone,
|
||||
password: req.body.password,
|
||||
});
|
||||
await createdUser.save();
|
||||
res.sendStatus(201);
|
||||
return;
|
||||
} catch (err) {
|
||||
if (err.name === "TypeError" || err.name === "ValidationError") {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.error(err);
|
||||
res.status(400).send(err.toString());
|
||||
} else {
|
||||
res.status(400).send("Missing required user info.");
|
||||
}
|
||||
} else if (err.name === "MongoServerError" && err.message.startsWith("E11000")) {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.error(err);
|
||||
res.status(409).send(err.toString());
|
||||
} else {
|
||||
res.status(409).send("User already exists.");
|
||||
}
|
||||
} else {
|
||||
console.error(err);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
res.status(500).send(err.toString());
|
||||
} else {
|
||||
res.status(500).send("Internal server error. This issue has been noted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default UserController;
|
2
server/database/mongoose.js
Normal file
@ -0,0 +1,2 @@
|
||||
export const mongooseDbName = process.env.DB_NAME || "sm_db";
|
||||
export const mongoURI = process.env.MONGODB_URI || "mongodb://127.0.0.1:27017";
|
30
server/middleware/authority.js
Normal file
@ -0,0 +1,30 @@
|
||||
import MongoStore from "connect-mongo";
|
||||
import session from "express-session";
|
||||
import { mongooseDbName, mongoURI } from "../database/mongoose.js";
|
||||
const sessionConf = {
|
||||
secret: process.env.SESSION_SECRET || "super duper secret string.",
|
||||
cookie: {
|
||||
expires: process.env.SESSION_TIMEOUT || 300000,
|
||||
httpOnly: true,
|
||||
},
|
||||
saveUninitialized: false,
|
||||
resave: false,
|
||||
};
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
sessionConf.cookie.secure = true;
|
||||
sessionConf.store = MongoStore.create({ mongoUrl: mongoURI, dbName: mongooseDbName });
|
||||
}
|
||||
export const userSession = session(sessionConf);
|
||||
|
||||
export function authenticationGuard(req, res, next) {
|
||||
if (req.session.userId) {
|
||||
next();
|
||||
} else {
|
||||
res.sendStatus(401);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Authentication
|
||||
// TODO: Identity
|
||||
// TODO: Authority
|
9
server/middleware/database.js
Normal file
@ -0,0 +1,9 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
export function needDatabase(res, req, next) {
|
||||
if (mongoose.connection.readyState != 1) {
|
||||
res.status(500).send("Internal server error: Database connection faulty.");
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
2740
server/package-lock.json
generated
@ -2,19 +2,28 @@
|
||||
"name": "server",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"develop": "NODE_ENV=development nodemon server.js",
|
||||
"start": "NODE_ENV=production node server.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"eslint": "^8.12.0"
|
||||
"eslint": "^8.12.0",
|
||||
"nodemon": "^2.0.15"
|
||||
},
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.0.1",
|
||||
"body-parser": "^1.19.2",
|
||||
"connect-mongo": "^4.6.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.3",
|
||||
"mongoose": "^6.2.8"
|
||||
"express-session": "^1.17.2",
|
||||
"mongoose": "^6.2.8",
|
||||
"validator": "^13.7.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.073c9b0a.css",
|
||||
"main.js": "/static/js/main.20b9b294.js",
|
||||
"static/js/787.c4e7f8f9.chunk.js": "/static/js/787.c4e7f8f9.chunk.js",
|
||||
"static/media/logo.svg": "/static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg",
|
||||
"index.html": "/index.html",
|
||||
"main.073c9b0a.css.map": "/static/css/main.073c9b0a.css.map",
|
||||
"main.20b9b294.js.map": "/static/js/main.20b9b294.js.map",
|
||||
"787.c4e7f8f9.chunk.js.map": "/static/js/787.c4e7f8f9.chunk.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.073c9b0a.css",
|
||||
"static/js/main.20b9b294.js"
|
||||
]
|
||||
}
|
@ -1 +0,0 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.20b9b294.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
@ -1,2 +0,0 @@
|
||||
body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{-webkit-animation:App-logo-spin 20s linear infinite;animation:App-logo-spin 20s linear infinite}}.App-header{align-items:center;background-color:#282c34;color:#fff;display:flex;flex-direction:column;font-size:calc(10px + 2vmin);justify-content:center;min-height:100vh}.App-link{color:#61dafb}@-webkit-keyframes App-logo-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes App-logo-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}
|
||||
/*# sourceMappingURL=main.073c9b0a.css.map*/
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"static/css/main.073c9b0a.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF,CCZA,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,mDAA4C,CAA5C,2CACF,CACF,CAEA,YAKE,kBAAmB,CAJnB,wBAAyB,CAOzB,UAAY,CALZ,YAAa,CACb,qBAAsB,CAGtB,4BAA6B,CAD7B,sBAAuB,CAJvB,gBAOF,CAEA,UACE,aACF,CAEA,iCACE,GACE,8BAAuB,CAAvB,sBACF,CACA,GACE,+BAAyB,CAAzB,uBACF,CACF,CAPA,yBACE,GACE,8BAAuB,CAAvB,sBACF,CACA,GACE,+BAAyB,CAAzB,uBACF,CACF","sources":["index.css","App.css"],"sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n",".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"],"names":[],"sourceRoot":""}
|
@ -1,2 +0,0 @@
|
||||
"use strict";(self.webpackChunkclient=self.webpackChunkclient||[]).push([[787],{787:function(e,t,n){n.r(t),n.d(t,{getCLS:function(){return y},getFCP:function(){return g},getFID:function(){return C},getLCP:function(){return P},getTTFB:function(){return D}});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,p=function(){return"hidden"===document.visibilityState?0:1/0},d=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=p(),d(),s((function(){setTimeout((function(){v=p(),d()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},p=c("layout-shift",v);p&&(n=m(i,r,t),f((function(){p.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),p=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},d=c("first-input",p);n=m(e,v,t),d&&f((function(){d.takeRecords().map(p),d.disconnect()}),!0),d&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=p,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
|
||||
//# sourceMappingURL=787.c4e7f8f9.chunk.js.map
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
object-assign
|
||||
(c) Sindre Sorhus
|
||||
@license MIT
|
||||
*/
|
||||
|
||||
/** @license React v0.20.2
|
||||
* scheduler.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v17.0.2
|
||||
* react-dom.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v17.0.2
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v17.0.2
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
27
server/schemas/matchModel.js
Normal file
@ -0,0 +1,27 @@
|
||||
import mongoose from "mongoose";
|
||||
import ModelNameRegister from "./modelNameRegister.js";
|
||||
|
||||
const Types = mongoose.Schema.Types; // Some types require defining from this object.
|
||||
|
||||
const matchSchema = new mongoose.Schema({
|
||||
title: { type: String, required: true, trim: true },
|
||||
when: { type: Date, required: true },
|
||||
publicity: { type: Number, required: true, default: 2 },
|
||||
location: {
|
||||
type: [Number],
|
||||
required: true,
|
||||
validate: {
|
||||
validator: function (v) {
|
||||
return v.length === 2;
|
||||
},
|
||||
message: "Invalid coordinate format (array not length of 2)."
|
||||
}
|
||||
},
|
||||
creator: { type: Types.ObjectId, ref: ModelNameRegister.User },
|
||||
participants: { type: [{ type: Types.ObjectId, ref: ModelNameRegister.User }], required: true, default: [] },
|
||||
difficulty: { type: Number, required: true },
|
||||
sport: { type: Types.ObjectId, ref: ModelNameRegister.Sport },
|
||||
createDate: { type: Date, required: true, default: Date.now }
|
||||
});
|
||||
|
||||
export default mongoose.model(ModelNameRegister.Match, matchSchema);
|
5
server/schemas/modelNameRegister.js
Normal file
@ -0,0 +1,5 @@
|
||||
export default {
|
||||
Match: "match",
|
||||
User: "user",
|
||||
Sport: "sport"
|
||||
};
|
19
server/schemas/sportModel.js
Normal file
@ -0,0 +1,19 @@
|
||||
import mongoose from "mongoose";
|
||||
import ModelNameRegister from "./modelNameRegister.js";
|
||||
|
||||
const sportSchema = new mongoose.Schema({
|
||||
name: { type: String, required: true, unique: true, trim: true },
|
||||
minPlayers: { type: Number, required: true, default: 1 },
|
||||
description: { type: String, required: true, trim: true }
|
||||
});
|
||||
|
||||
sportSchema.pre("save", function (next) {
|
||||
this.name = this.name.toLowerCase();
|
||||
next();
|
||||
});
|
||||
|
||||
sportSchema.statics.findByName = function (name) {
|
||||
return this.findOne({ name: name.trim().toLowerCase() });
|
||||
};
|
||||
|
||||
export default mongoose.model(ModelNameRegister.Sport, sportSchema);
|
68
server/schemas/userModel.js
Normal file
@ -0,0 +1,68 @@
|
||||
import mongoose from "mongoose";
|
||||
import validator from "validator";
|
||||
import bcrypt from "bcrypt";
|
||||
import modelNameRegister from "./modelNameRegister.js";
|
||||
|
||||
const Types = mongoose.Schema.Types;
|
||||
|
||||
const userSchema = new mongoose.Schema({
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
minlength: 1,
|
||||
trim: true,
|
||||
unique: true,
|
||||
validate: {
|
||||
validator: validator.isEmail,
|
||||
message: "String not email.",
|
||||
}
|
||||
},
|
||||
firstName: { type: String, required: true, trim: true },
|
||||
lastName: { type: String, required: true, trim: true },
|
||||
joinDate: { type: Date, default: Date.now, required: true },
|
||||
phone: { type: Number, required: false, min: 0 },
|
||||
password: {
|
||||
type: String,
|
||||
required: true,
|
||||
minlength: 8
|
||||
// TODO: Custom validator for password requirements?
|
||||
},
|
||||
createdMatches: { type: [{ type: Types.ObjectId, ref: modelNameRegister.Match }], required: true, default: [] },
|
||||
participatingMatches: { type: [{ type: Types.ObjectId, ref: modelNameRegister.Match }], required: true, default: [] },
|
||||
emailPublicity: { type: Number, required: true, default: 0 },
|
||||
bioPublicity: { type: Boolean, required: true, default: false },
|
||||
phonePublicity: { type: Boolean, required: true, default: false },
|
||||
participatingMatchesPublicity: { type: Boolean, required: true, default: false },
|
||||
friends: { type: Types.ObjectId, ref: modelNameRegister.User },
|
||||
accessLevel: { type: Number, required: true, default: 0 },
|
||||
});
|
||||
|
||||
userSchema.statics.credentialsExist = async function (email, password) {
|
||||
let userModel = this;
|
||||
let user = await userModel.findOne({ email: email });
|
||||
if (!user) {
|
||||
return Promise.reject(new Error("Credentials do not exist."));
|
||||
}
|
||||
if (await bcrypt.compare(password, user.password)) {
|
||||
return user;
|
||||
}
|
||||
};
|
||||
|
||||
userSchema.pre("save", function (next) {
|
||||
let user = this;
|
||||
if (user.isModified("password")) { // Only perform hashing if the password has changed.
|
||||
bcrypt.genSalt(10, (err, salt) => {
|
||||
bcrypt.hash(user.password, salt, (err, hash) => {
|
||||
if (err) {
|
||||
throw err; // Probably not, but I'm gonna leave this here for now.
|
||||
}
|
||||
user.password = hash;
|
||||
next();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default mongoose.model(modelNameRegister.User, userSchema);
|
@ -1,5 +1,47 @@
|
||||
import express from "express";
|
||||
import bodyParser from "body-parser";
|
||||
import mongoose from "mongoose";
|
||||
import UserController from "./controllers/userController.js";
|
||||
import MatchController from "./controllers/matchController.js";
|
||||
import SportController from "./controllers/sportController.js";
|
||||
import { userSession } from "./middleware/authority.js";
|
||||
import { mongooseDbName, mongoURI } from "./database/mongoose.js";
|
||||
import cors from "cors";
|
||||
|
||||
const server = express();
|
||||
const port = process.env.PORT || 5000;
|
||||
|
||||
server.use(express.static("public")); // For all client files.
|
||||
|
||||
// Connection documentation: https://mongoosejs.com/docs/connections.html
|
||||
try {
|
||||
mongoose.connect(mongoURI, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
dbName: mongooseDbName,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
mongoose.set("bufferCommands", false); // We want to know if there are connection issues immediately for development. Disables globally.
|
||||
|
||||
server.use(cors());
|
||||
}
|
||||
|
||||
// Docs: https://www.npmjs.com/package/body-parser
|
||||
server.use(bodyParser.json());
|
||||
server.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
server.use(userSession);
|
||||
|
||||
server.use("/user", UserController);
|
||||
server.use("/match", MatchController);
|
||||
server.use("/sport", SportController);
|
||||
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log(`Server listening on port ${port}.`);
|
||||
});
|
350
sports-matcher/.gitignore
vendored
Normal file
@ -0,0 +1,350 @@
|
||||
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,node,python,react
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,node,python,react
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
### react ###
|
||||
.DS_*
|
||||
**/*.backup.*
|
||||
**/*.back.*
|
||||
|
||||
node_modules
|
||||
|
||||
*.sublime*
|
||||
|
||||
psd
|
||||
thumb
|
||||
sketch
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
# Support for Project snippet scope
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,node,python,react
|
||||
|
||||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
||||
|
||||
server/mongo-data/**
|
3
sports-matcher/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Sports Matcher
|
||||
|
||||
A CSC309 Project.
|
41
sports-matcher/client/.eslintrc.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:react/jsx-runtime"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
4
|
||||
],
|
||||
"linebreak-style": [
|
||||
"warn",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"double"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"no-unused-vars": "warn"
|
||||
}
|
||||
}
|
23
sports-matcher/client/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
70
sports-matcher/client/README.md
Normal file
@ -0,0 +1,70 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
||||
|
||||
The page will reload when you make changes.\
|
||||
You may also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
|
||||
### Code Splitting
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
||||
|
||||
### Making a Progressive Web App
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
||||
|
||||
### Deployment
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
||||
|
||||
### `npm run build` fails to minify
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
28053
sports-matcher/client/package-lock.json
generated
Normal file
47
sports-matcher/client/package.json
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "client",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@testing-library/jest-dom": "^5.16.3",
|
||||
"@testing-library/react": "^12.1.4",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"axios": "^0.26.1",
|
||||
"bootstrap": "^5.1.3",
|
||||
"react": "^17.0.2",
|
||||
"react-bootstrap": "^2.2.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "^6.2.2",
|
||||
"react-scripts": "5.0.0",
|
||||
"validator": "^13.7.0",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "NODE_ENV='development' REACT_APP_API_HOST='http://localhost:5000' react-scripts start",
|
||||
"build": "../scripts/build.py",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-plugin-react": "^7.29.4"
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 529 KiB |
After Width: | Height: | Size: 496 KiB |
After Width: | Height: | Size: 396 KiB |
After Width: | Height: | Size: 894 KiB |
After Width: | Height: | Size: 592 KiB |
43
sports-matcher/client/public/index.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
8
sports-matcher/client/src/App.test.js
Normal file
@ -0,0 +1,8 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
86
sports-matcher/client/src/Layout.js
Normal file
@ -0,0 +1,86 @@
|
||||
import "./styles/Layout.css";
|
||||
import "./styles/extra.css";
|
||||
import { useState } from "react";
|
||||
import { NavLink, Route, Routes, useNavigate } from "react-router-dom";
|
||||
import Welcome from "./pages/Welcome";
|
||||
import Navbar from "react-bootstrap/Navbar";
|
||||
import { Container, Nav, NavbarBrand } from "react-bootstrap";
|
||||
import NavbarToggle from "react-bootstrap/esm/NavbarToggle";
|
||||
import NavbarCollapse from "react-bootstrap/esm/NavbarCollapse";
|
||||
import Dashboard from "./pages/Dashboard";
|
||||
import Logout from "./pages/Logout";
|
||||
import Rentals from "./pages/Rentals";
|
||||
import Admin from "./pages/Administration";
|
||||
import Login from "./pages/Login";
|
||||
import Context from "./globals.js";
|
||||
import Signup from "./pages/Signup";
|
||||
|
||||
|
||||
export default function layout() {
|
||||
const [globals, setGlobals] = useState({
|
||||
user: null,
|
||||
update: (updates, onUpdate) => setGlobals((state) => { return { ...state, ...updates }; }, onUpdate),
|
||||
navigate: useNavigate()
|
||||
});
|
||||
|
||||
let identityDisplay = (
|
||||
<Nav>
|
||||
<li className="nav-item">
|
||||
<NavLink className="nav-link" to="/login" >Login</NavLink>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
<NavLink className="nav-link" to="/signup" >Sign up!</NavLink>
|
||||
</li>
|
||||
</Nav>
|
||||
);
|
||||
|
||||
if (globals.user) {
|
||||
identityDisplay = (
|
||||
<Nav>
|
||||
<li className="nav-item">
|
||||
<NavLink className="nav-link" to="/" >Hi, {globals.user.firstName}</NavLink>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
<NavLink className="nav-link" to="/logout" >Logout</NavLink>
|
||||
</li>
|
||||
</Nav>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div id="app">
|
||||
<Context.Provider value={globals}>
|
||||
<header>
|
||||
<Navbar bg="light" expand="md">
|
||||
<Container>
|
||||
<NavbarBrand href="/">Sports Matcher</NavbarBrand>
|
||||
<NavbarToggle aria-controls="navigation"></NavbarToggle>
|
||||
<NavbarCollapse id="main-nav">
|
||||
<Nav className="me-auto">
|
||||
<li className="nav-item">
|
||||
<NavLink className="nav-link" to="/" >Home</NavLink>
|
||||
</li>
|
||||
</Nav>
|
||||
{identityDisplay}
|
||||
</NavbarCollapse>
|
||||
</Container>
|
||||
</Navbar>
|
||||
</header>
|
||||
<main>
|
||||
<Routes>
|
||||
<Route path="/" element={<Welcome />} />
|
||||
<Route path="/dashboard" element={<Dashboard />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/signup" element={<Signup />} />
|
||||
<Route path="/logout" element={<Logout />} />
|
||||
<Route path="/admin" element={<Admin />} />
|
||||
<Route path="/rentals" element={<Rentals />} />
|
||||
</Routes>
|
||||
</main>
|
||||
<footer>
|
||||
|
||||
</footer>
|
||||
</Context.Provider>
|
||||
</div>
|
||||
);
|
||||
}
|
44
sports-matcher/client/src/components/AuthenticationGuard.js
Normal file
@ -0,0 +1,44 @@
|
||||
import React from "react";
|
||||
import globals from "../globals";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
import propTypes from "prop-types";
|
||||
|
||||
export default class AuthenticationGuard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static contextType = globals;
|
||||
|
||||
async componentDidMount() {
|
||||
let userDataResponse = await apiClient.get("/user");
|
||||
if (userDataResponse.status === 200) {
|
||||
this.context.update({ user: userDataResponse.data });
|
||||
if (this.context.user && this.context.user.accessLevel < this.props.accessLevel) {
|
||||
this.context.navigate("/", { replace: true });
|
||||
}
|
||||
} else if (userDataResponse.status == 401) {
|
||||
this.context.navigate("/signup", { replace: true });
|
||||
this.context.update({ user: null });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.context.user) {
|
||||
return this.props.children;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AuthenticationGuard.defaultProps = {
|
||||
accessLevel: 0
|
||||
};
|
||||
|
||||
AuthenticationGuard.propTypes = {
|
||||
accessLevel: propTypes.number,
|
||||
children: propTypes.any
|
||||
};
|
53
sports-matcher/client/src/components/HomeCarousel.js
Normal file
@ -0,0 +1,53 @@
|
||||
import React from "react";
|
||||
import { Carousel } from "react-bootstrap";
|
||||
export default class HomeCarousel extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<Carousel className="jumbotron" variant="light">
|
||||
<Carousel.Item>
|
||||
<img
|
||||
className="d-block w-100"
|
||||
src='/images/carousel/volleyball_normalized.jpg'
|
||||
alt="Connect Slide"
|
||||
/>
|
||||
<Carousel.Caption>
|
||||
<div className="captionStyle">
|
||||
<h1>Connect</h1>
|
||||
<h2>Connect with other athletes in your area!</h2>
|
||||
</div>
|
||||
</Carousel.Caption>
|
||||
</Carousel.Item>
|
||||
<Carousel.Item>
|
||||
<img
|
||||
className="d-block w-100"
|
||||
src='/images/carousel/schedule_normalized.jpg'
|
||||
alt="Schedule Slide"
|
||||
/>
|
||||
<Carousel.Caption>
|
||||
<div className="captionStyle">
|
||||
<h1>Schedule</h1>
|
||||
<h2>Schedule sport meets with other athletes!</h2>
|
||||
</div>
|
||||
</Carousel.Caption>
|
||||
</Carousel.Item>
|
||||
<Carousel.Item>
|
||||
<img
|
||||
src='/images/carousel/rentals_normalized.jpg'
|
||||
alt="Rent Slide"
|
||||
className="d-block w-100"
|
||||
/>
|
||||
<Carousel.Caption>
|
||||
<div className="captionStyle">
|
||||
<h1>Rent</h1>
|
||||
<h2>Rent sports equipment from other athletes!</h2>
|
||||
</div>
|
||||
</Carousel.Caption>
|
||||
</Carousel.Item>
|
||||
</Carousel>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
36
sports-matcher/client/src/components/MatchInfoCard.js
Normal file
@ -0,0 +1,36 @@
|
||||
import React from "react";
|
||||
import { Button, Card } from "react-bootstrap";
|
||||
import propTypes from "prop-types";
|
||||
import { grammaticalListString } from "../utils/strings";
|
||||
export default class MatchInfoCard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
getParticipants() {
|
||||
let participants = [];
|
||||
this.props.match.participants.forEach(user => {
|
||||
participants.push(user.firstName);
|
||||
});
|
||||
return participants;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Card style={{ width: "20rem" }}>
|
||||
<Card.Body>
|
||||
<Card.Title>{this.props.match.sport.name}</Card.Title>
|
||||
<Card.Subtitle className="mb-2 text-muted">{this.props.match.title}</Card.Subtitle>
|
||||
<Card.Text>
|
||||
Join <strong>{grammaticalListString(this.getParticipants(), 4)}</strong> to play a few matches of <strong>{this.props.match.sport.name}</strong> at <strong>{this.props.match.location.toString()}</strong> on <strong>{new Date(this.props.match.when).toLocaleDateString("en-US")}</strong>!
|
||||
</Card.Text>
|
||||
<Button variant="primary">Join!</Button>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MatchInfoCard.propTypes = {
|
||||
match: propTypes.object,
|
||||
};
|
24
sports-matcher/client/src/components/MatchInfoCardDisplay.js
Normal file
@ -0,0 +1,24 @@
|
||||
import React from "react";
|
||||
import propTypes from "prop-types";
|
||||
import MatchInfoCard from "./MatchInfoCard";
|
||||
import "../styles/MatchInfoCardDisplay.css";
|
||||
export default class MatchInfoCardDisplay extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
let matches = null;
|
||||
if (this.props.recommendedmatches.length > 0) {
|
||||
matches = this.props.recommendedmatches.map((match) => <MatchInfoCard key={match._id} match={match}></MatchInfoCard>);
|
||||
}
|
||||
return (
|
||||
<div className="horizontal-scroller">
|
||||
{matches}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MatchInfoCardDisplay.propTypes = {
|
||||
recommendedmatches: propTypes.array,
|
||||
};
|
31
sports-matcher/client/src/components/RentalInfoCard.js
Normal file
@ -0,0 +1,31 @@
|
||||
import React from "react";
|
||||
import { Card } from "react-bootstrap";
|
||||
//import { Button, Card } from "react-bootstrap";
|
||||
import propTypes from "prop-types";
|
||||
//import { grammaticalListString } from "../utils/strings";
|
||||
export default class MatchInfoCard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
return (
|
||||
// <Card style={{ width: "20rem" }}>
|
||||
<Card>
|
||||
<Card.Body>
|
||||
<Card.Title>{this.props.rental.title}</Card.Title>
|
||||
<Card.Text className="mb-2 text-muted">Rate: {this.props.rental.rate}</Card.Text>
|
||||
<Card.Text>Date Created: {this.props.rental.createDate}</Card.Text>
|
||||
<Card.Text>Owner: {this.props.rental.creator}</Card.Text>
|
||||
<Card.Text>Contact: {this.props.rental.contact}</Card.Text>
|
||||
<Card.Text>Description: {this.props.rental.description}</Card.Text>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MatchInfoCard.propTypes = {
|
||||
rental: propTypes.object,
|
||||
};
|
26
sports-matcher/client/src/components/SportInfoCard.js
Normal file
@ -0,0 +1,26 @@
|
||||
import React from "react";
|
||||
import { Card } from "react-bootstrap";
|
||||
import propTypes from "prop-types";
|
||||
export default class SportInfoCard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Card style={{ width: "20rem" }}>
|
||||
<Card.Body>
|
||||
<Card.Title>{this.props.sport.name}</Card.Title>
|
||||
<Card.Subtitle className="mb-2 text-muted">Requires a minimum of {this.props.sport.minPlayers.toString()} players.</Card.Subtitle>
|
||||
<Card.Text>
|
||||
{this.props.sport.description}
|
||||
</Card.Text>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SportInfoCard.propTypes = {
|
||||
sport: propTypes.object,
|
||||
};
|
24
sports-matcher/client/src/components/SportInfoCardDisplay.js
Normal file
@ -0,0 +1,24 @@
|
||||
import React from "react";
|
||||
import propTypes from "prop-types";
|
||||
import SportInfoCard from "./SportInfoCard";
|
||||
import "../styles/MatchInfoCardDisplay.css";
|
||||
export default class SportInfoCardDisplay extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
let sports = null;
|
||||
if (this.props.recommendedsports.length > 0) {
|
||||
sports = this.props.recommendedsports.map((sport) => <SportInfoCard key={sport._id} sport={sport}></SportInfoCard>);
|
||||
}
|
||||
return (
|
||||
<div className="horizontal-scroller">
|
||||
{sports}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SportInfoCardDisplay.propTypes = {
|
||||
recommendedsports: propTypes.array,
|
||||
};
|
7
sports-matcher/client/src/globals.js
Normal file
@ -0,0 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
export default React.createContext({
|
||||
user: null,
|
||||
update: () => { },
|
||||
navigate: () => { }
|
||||
});
|
22
sports-matcher/client/src/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import Layout from "./Layout";
|
||||
import reportWebVitals from "./reportWebVitals";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import "bootstrap/dist/css/bootstrap.min.css"; // This could be optimized by importing individual css components.
|
||||
|
||||
console.log(process.env);
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<BrowserRouter>
|
||||
<Layout />
|
||||
</BrowserRouter>
|
||||
</React.StrictMode>,
|
||||
document.getElementById("root")
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
251
sports-matcher/client/src/pages/Administration.js
Normal file
@ -0,0 +1,251 @@
|
||||
import React from "react";
|
||||
import { Button, ButtonGroup, Spinner, Table } from "react-bootstrap";
|
||||
import "../styles/Admin.css";
|
||||
import globals from "../globals";
|
||||
import AuthenticationGuard from "../components/AuthenticationGuard";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
|
||||
export default class Admin extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
// Use null to indicate not loaded
|
||||
// Use empty array to indicate no items for that state.
|
||||
this.state = {
|
||||
users: null,
|
||||
suspendedUsers: null,
|
||||
matches: null,
|
||||
user: null,
|
||||
currentTab: "matches",
|
||||
};
|
||||
}
|
||||
|
||||
static contextType = globals;
|
||||
|
||||
async componentDidMount() {
|
||||
await this.loadActiveUsers();
|
||||
await this.loadSuspendedUsers();
|
||||
await this.loadMatches();
|
||||
}
|
||||
|
||||
async loadActiveUsers() {
|
||||
let response = await apiClient.get("/user/all/active");
|
||||
if (response.status === 200) {
|
||||
this.setState({ users: response.data.active });
|
||||
}
|
||||
}
|
||||
|
||||
async loadSuspendedUsers() {
|
||||
let response = await apiClient.get("/user/all/suspended");
|
||||
if (response.status === 200) {
|
||||
this.setState({ suspendedUsers: response.data.suspended });
|
||||
} else {
|
||||
console.error(response.status);
|
||||
}
|
||||
}
|
||||
|
||||
async loadMatches() {
|
||||
let response = await apiClient.get("/match/all");
|
||||
if (response.status === 200) {
|
||||
this.setState({ matches: response.data.all });
|
||||
}
|
||||
}
|
||||
|
||||
DeleteButton() {
|
||||
return <Button onClick={() => {
|
||||
alert("User deleted.");
|
||||
}} variant="outline-secondary">Delete</Button>;
|
||||
|
||||
}
|
||||
|
||||
PardonButton() {
|
||||
return <Button onClick={() => {
|
||||
alert("User pardoned.");
|
||||
}} variant="outline-secondary">Pardon</Button>;
|
||||
|
||||
}
|
||||
|
||||
EditButton() {
|
||||
return <Button onClick={() => {
|
||||
alert("clicked");
|
||||
}} variant="outline-secondary">Edit</Button>;
|
||||
|
||||
}
|
||||
|
||||
userTableHead() {
|
||||
return (
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Username</th>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
);
|
||||
}
|
||||
|
||||
matchTableHead() {
|
||||
return (
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Sport</th>
|
||||
<th>Date</th>
|
||||
<th>Location</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
userTableData() {
|
||||
if (!this.state.users) {
|
||||
return (
|
||||
<tr>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
return this.state.users.map((user) => {
|
||||
const { _id, firstName, lastName, email, phone } = user;
|
||||
return (
|
||||
<tr key={_id}>
|
||||
<td>{_id}</td>
|
||||
<td>{firstName}</td>
|
||||
<td>{lastName}</td>
|
||||
<td>{email}</td>
|
||||
<td>{phone}</td>
|
||||
<td>{this.DeleteButton()}</td>
|
||||
<td>{this.EditButton()}</td>
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
susUserTableData() {
|
||||
if (!this.state.suspendedUsers) {
|
||||
return (
|
||||
<tr>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return this.state.suspendedUsers.map((user) => {
|
||||
const { _id, firstName, lastName, email, phone } = user;
|
||||
return (
|
||||
<tr key={_id}>
|
||||
<td>{_id}</td>
|
||||
<td>{firstName}</td>
|
||||
<td>{lastName}</td>
|
||||
<td>{email}</td>
|
||||
<td>{phone}</td>
|
||||
<td>{this.DeleteButton()}</td>
|
||||
<td>{this.EditButton()}</td>
|
||||
<td>{this.PardonButton()}</td>
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
matchTableData() {
|
||||
if (!this.state.matches) {
|
||||
return (
|
||||
<tr>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
<td><Spinner animation="grow" /></td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return this.state.matches.map((match) => {
|
||||
const { _id, sport, when, location } = match;
|
||||
const sportName = sport.name;
|
||||
return (
|
||||
<tr key={_id}>
|
||||
<td>{_id}</td>
|
||||
<td>{sportName}</td>
|
||||
<td>{when}</td>
|
||||
<td>{location}</td>
|
||||
<td>{this.DeleteButton()}</td>
|
||||
<td>{this.EditButton()}</td>
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
renderTableHead() {
|
||||
if (this.state.currentTab === "matches") {
|
||||
return this.matchTableHead();
|
||||
} else if (this.state.currentTab === "users") {
|
||||
return this.userTableHead();
|
||||
} else {
|
||||
return this.userTableHead();
|
||||
}
|
||||
}
|
||||
|
||||
renderTableData() {
|
||||
if (this.state.currentTab === "matches") {
|
||||
return this.matchTableData();
|
||||
} else if (this.state.currentTab === "users") {
|
||||
return this.userTableData();
|
||||
} else {
|
||||
return this.susUserTableData();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root">
|
||||
<AuthenticationGuard accessLevel={3}>
|
||||
<React.Fragment>
|
||||
<div className='center'>
|
||||
<h1 id='title'>Administration</h1>
|
||||
<ButtonGroup aria-label="Pages">
|
||||
<Button onClick={() => {
|
||||
this.setState({ currentTab: "matches" });
|
||||
}} variant="outline-secondary" active={this.state.currentTab === "matches"}>Matches</Button>
|
||||
<Button onClick={() => {
|
||||
this.setState({ currentTab: "users" });
|
||||
}} variant="outline-secondary" active={this.state.currentTab === "users"}>Users</Button>
|
||||
<Button onClick={() => {
|
||||
this.setState({ currentTab: "suspended" });
|
||||
}} variant="outline-secondary" active={this.state.currentTab === "suspended"}>Suspended Users</Button>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
<Table striped bordered hover>
|
||||
{this.renderTableHead()}
|
||||
<tbody>
|
||||
{this.renderTableData()}
|
||||
{/* {this.matchUserTableData()} */}
|
||||
</tbody>
|
||||
</Table>
|
||||
</React.Fragment>
|
||||
</AuthenticationGuard >
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
71
sports-matcher/client/src/pages/Dashboard.js
Normal file
@ -0,0 +1,71 @@
|
||||
import React from "react";
|
||||
import { Button, InputGroup, FormControl } from "react-bootstrap";
|
||||
import "../styles/Dashboard.css";
|
||||
import { apiClient } from "../utils/httpClients.js";
|
||||
import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
|
||||
import SportInfoCardDisplay from "../components/SportInfoCardDisplay";
|
||||
import AuthenticationGuard from "../components/AuthenticationGuard";
|
||||
import globals from "../globals";
|
||||
|
||||
export default class Dashboard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
displayedMatches: [],
|
||||
displayedSports: [],
|
||||
displayedEquipment: [],
|
||||
user: null
|
||||
};
|
||||
}
|
||||
|
||||
static contextType = globals;
|
||||
|
||||
async componentDidMount() {
|
||||
this.setState({ user: this.context.user });
|
||||
await this.latestMatches();
|
||||
await this.availableSports();
|
||||
}
|
||||
async latestMatches() {
|
||||
let recentMatchesRes = await apiClient.get("/match/recent/user/15");
|
||||
if (recentMatchesRes.status === 200) {
|
||||
this.setState({ displayedMatches: recentMatchesRes.data.recent });
|
||||
}
|
||||
}
|
||||
|
||||
async availableSports() {
|
||||
let availableSportsRes = await apiClient.get("/sport");
|
||||
if (availableSportsRes.status === 200) {
|
||||
this.setState({ displayedSports: availableSportsRes.data });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<AuthenticationGuard>
|
||||
<div className="page-root">
|
||||
<React.Fragment>
|
||||
<h1></h1>
|
||||
<InputGroup className="w-50">
|
||||
<FormControl
|
||||
placeholder="Search for Matches"
|
||||
aria-label="Search Bar"
|
||||
aria-describedby="basic-addon2"
|
||||
/>
|
||||
<Button variant="outline-secondary" id="button-addon2">
|
||||
Search
|
||||
</Button>
|
||||
</InputGroup>
|
||||
<div className="p-4">
|
||||
<h2>Available Matches</h2>
|
||||
<MatchInfoCardDisplay recommendedmatches={this.state.displayedMatches} />
|
||||
</div>
|
||||
<div className="p-4">
|
||||
<h2>Available Sports</h2>
|
||||
<SportInfoCardDisplay recommendedsports={this.state.displayedSports} />
|
||||
</div>
|
||||
</React.Fragment>
|
||||
</div>
|
||||
</AuthenticationGuard>
|
||||
);
|
||||
}
|
||||
}
|
87
sports-matcher/client/src/pages/Login.js
Normal file
@ -0,0 +1,87 @@
|
||||
import React from "react";
|
||||
import { Alert, Button, Card, Container, Form } from "react-bootstrap";
|
||||
import globals from "../globals";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
|
||||
export default class Login extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
email: "",
|
||||
password: "",
|
||||
errorDisplayed: false,
|
||||
};
|
||||
|
||||
this.attemptLogin = this.attemptLogin.bind(this);
|
||||
}
|
||||
|
||||
static contextType = globals;
|
||||
|
||||
async componentDidMount() {
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.context.user) {
|
||||
this.context.navigate("/dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
async attemptLogin(e) {
|
||||
e.preventDefault();
|
||||
const loginResponse = await apiClient.post("/user/login", {
|
||||
email: this.state.email,
|
||||
password: this.state.password,
|
||||
});
|
||||
if (loginResponse.status === 200) {
|
||||
this.context.update({ user: loginResponse.data });
|
||||
} else if (loginResponse.status === 401) {
|
||||
this.setState({ errorDisplayed: true });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let errorMsg = (
|
||||
<div></div>
|
||||
);
|
||||
if (this.state.errorDisplayed) {
|
||||
errorMsg = (
|
||||
< Alert variant="danger" onClose={() => this.setState({ errorDisplayed: false })} dismissible >
|
||||
<Alert.Heading>Incorrect credentials</Alert.Heading>
|
||||
<p>Double check your provided e-mail and password!</p>
|
||||
</Alert >
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="d-flex justify-content-center align-items-center
|
||||
page-root">
|
||||
{errorMsg}
|
||||
<Container style={{ maxWidth: "35rem" }}>
|
||||
<Card>
|
||||
<Card.Body>
|
||||
<Card.Title>Login</Card.Title>
|
||||
<Card.Subtitle>Welcome back!</Card.Subtitle>
|
||||
<Form onSubmit={this.attemptLogin}>
|
||||
<Form.Group className="mb-3" controlId="loginEmail">
|
||||
<Form.Label>E-mail</Form.Label>
|
||||
<Form.Control type="email" placeholder="Ex. youremail@mail.com" onChange={(e) => {
|
||||
this.setState({ email: e.target.value });
|
||||
}} />
|
||||
</Form.Group>
|
||||
<Form.Group className="mb-3" controlId="loginPassword">
|
||||
<Form.Label>Password</Form.Label>
|
||||
<Form.Control type="password" placeholder="Enter password" onChange={(e) => {
|
||||
this.setState({ password: e.target.value });
|
||||
}} />
|
||||
</Form.Group>
|
||||
<Button variant="primary" type="submit">
|
||||
Submit
|
||||
</Button>
|
||||
</Form>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
39
sports-matcher/client/src/pages/Logout.js
Normal file
@ -0,0 +1,39 @@
|
||||
import React from "react";
|
||||
import globals from "../globals";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
|
||||
export default class Logout extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
static contextType = globals;
|
||||
|
||||
async componentDidMount() {
|
||||
const logoutResponse = await apiClient.get("/user/logout");
|
||||
if (logoutResponse.status === 200) {
|
||||
this.redirectTimer = setTimeout(() => {
|
||||
this.context.navigate("/", { replace: true });
|
||||
}, 2000);
|
||||
} else if (logoutResponse.status == 401) {
|
||||
this.context.navigate("/", { replace: true });
|
||||
}
|
||||
|
||||
this.context.update({ user: null });
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.redirectTimer);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root">
|
||||
<div>
|
||||
<h1>You are now logged out. See you later!</h1>
|
||||
<p className="text-muted">We will redirect you shortly...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
14
sports-matcher/client/src/pages/Profile.js
Normal file
@ -0,0 +1,14 @@
|
||||
import React from "react";
|
||||
import { Container } from "react-bootstrap";
|
||||
|
||||
export default class Profile extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root">
|
||||
<Container>
|
||||
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
89
sports-matcher/client/src/pages/Rentals.js
Normal file
@ -0,0 +1,89 @@
|
||||
import React from "react";
|
||||
import { Button, InputGroup, FormControl } from "react-bootstrap";
|
||||
import "../styles/Dashboard.css";
|
||||
// import { apiClient } from "../utils/httpClients.js";
|
||||
// import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
|
||||
// import SportInfoCardDisplay from "../components/SportInfoCardDisplay";
|
||||
import RentalInfoCard from "../components/RentalInfoCard";
|
||||
// import AuthenticationGuard from "../components/AuthenticationGuard";
|
||||
// import globals from "../globals";
|
||||
|
||||
export default class Rentals extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
rentals: [
|
||||
{ id: 9, creator: "Person5", createDate: "05/21/2022", title: "Horse", rate: "$1000/day", description: "This is an amazing horse, has won many races", contact: "647 765 1234" },
|
||||
{ id: 7, creator: "Person1", createDate: "05/05/2022", title: "Tennis Racquet", rate: "$300/day", description: "This is an amazing tennis racquet, used by Roger Federer to win Wimbledon in 2003", contact: "123 456 7890" },
|
||||
{ id: 3, creator: "Person2", createDate: "05/11/2022", title: "Soccer Ball", rate: "$70/day", description: "This is an amazing soccer ball, signed by Messi", contact: "647 822 4321" },
|
||||
{ id: 2, creator: "Person3", createDate: "05/13/2022", title: "Basket Ball", rate: "$7/day", description: "This is an amazing basketball, same model as the ones used in the NBA", contact: "467 279 4321" },
|
||||
{ id: 1, creator: "Person4", createDate: "05/18/2022", title: "Table Tennis Racquet", rate: "$7/day", description: "This is an amazing table tennis racquet, it's very good", contact: "326 111 4321" },
|
||||
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
// static contextType = globals;
|
||||
|
||||
// async componentDidMount() {
|
||||
// this.setState({ user: this.context.user });
|
||||
// await this.latestMatches();
|
||||
// await this.availableSports();
|
||||
// }
|
||||
// async latestMatches() {
|
||||
// let recentMatchesRes = await apiClient.get("/match/recent/user/15");
|
||||
// if (recentMatchesRes.status === 200) {
|
||||
// this.setState({ displayedMatches: recentMatchesRes.data.recent });
|
||||
// }
|
||||
// }
|
||||
|
||||
// async availableSports() {
|
||||
// let availableSportsRes = await apiClient.get("/sport");
|
||||
// if (availableSportsRes.status === 200) {
|
||||
// this.setState({ displayedSports: availableSportsRes.data });
|
||||
// }
|
||||
// }
|
||||
|
||||
// renderRentals() {
|
||||
// let matches = null;
|
||||
// if (this.props.recommendedmatches.length > 0) {
|
||||
// matches = this.props.recommendedmatches.map((match) => <MatchInfoCard key={match._id} match={match}></MatchInfoCard>);
|
||||
// }
|
||||
// return (
|
||||
// <div className="horizontal-scroller">
|
||||
// {matches}
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
|
||||
rentalsCards() {
|
||||
return this.state.rentals.map((rental) => {
|
||||
return (<RentalInfoCard key={rental.id} rental={rental}></RentalInfoCard>);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
<div className="page-root">
|
||||
<React.Fragment>
|
||||
<h1></h1>
|
||||
<InputGroup className="w-50">
|
||||
<FormControl
|
||||
placeholder="Search for Rentals"
|
||||
aria-label="Search Bar"
|
||||
aria-describedby="basic-addon2"
|
||||
/>
|
||||
<Button variant="outline-secondary" id="button-addon2">
|
||||
Search
|
||||
</Button>
|
||||
</InputGroup>
|
||||
<div className="p-4">
|
||||
<h2>Available Rentals</h2>
|
||||
{this.rentalsCards()}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
147
sports-matcher/client/src/pages/Signup.js
Normal file
@ -0,0 +1,147 @@
|
||||
import React from "react";
|
||||
import { Alert, Button, Card, Container, Form } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import validator from "validator";
|
||||
import globals from "../globals";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
|
||||
export default class Signup extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
user: {
|
||||
email: null,
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
phone: null,
|
||||
password: null
|
||||
},
|
||||
alert: {
|
||||
show: false,
|
||||
variant: null,
|
||||
headerMsg: null,
|
||||
content: null
|
||||
}
|
||||
};
|
||||
|
||||
this.registerUser = this.registerUser.bind(this);
|
||||
this.setUserState = this.setUserState.bind(this);
|
||||
}
|
||||
|
||||
static contextType = globals;
|
||||
|
||||
async registerUser(event) {
|
||||
event.preventDefault();
|
||||
let formIssues = this.validateCurrentForm();
|
||||
if (formIssues.length > 0) {
|
||||
this.notifyUser("Oops there were issue(s)", (
|
||||
<ul>
|
||||
{formIssues.map((issue) => {
|
||||
return (
|
||||
<li key={issue}>{issue}</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
), "danger");
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await apiClient.post("/user", this.state.user);
|
||||
if (res.status === 201) {
|
||||
this.notifyUser("Success!", <div>You are successfully signed up! You wil be directed to <Link to="/login">login</Link> now.</div>, "success");
|
||||
this.redirectTimer = setTimeout(() => {
|
||||
this.context.navigate("/signin", { replace: true });
|
||||
}, 1000);
|
||||
} else if (res.status === 409) {
|
||||
this.notifyUser("User exists!", <div>This user already exists. Try <Link to="/login">logging in</Link> instead.</div>, "danger");
|
||||
} else if (res.status === 400) {
|
||||
this.notifyUser("There were errors in the submitted info.", <div>Double check to see if everything is inputted is valid.</div>, "danger");
|
||||
} else {
|
||||
this.notifyUser("Error", <div>Internal server error. Please try again later.</div>, "danger");
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.redirectTimer);
|
||||
}
|
||||
|
||||
validateCurrentForm() {
|
||||
let formIssues = [];
|
||||
if (!validator.isEmail(this.state.user.email)) {
|
||||
formIssues.push("The email submitted is invalid.");
|
||||
}
|
||||
|
||||
if (this.state.user.password.length < 8) {
|
||||
formIssues.push("The password submitted must have a minimum length of 8 characters.");
|
||||
}
|
||||
|
||||
return formIssues;
|
||||
}
|
||||
|
||||
setUserState(event) {
|
||||
this.setState((state) => {
|
||||
state.user[event.target.id] = event.target.value;
|
||||
return state;
|
||||
});
|
||||
}
|
||||
|
||||
notifyUser(headerMsg, content, key) {
|
||||
this.setState((state) => {
|
||||
state.alert.show = true;
|
||||
state.alert.headerMsg = headerMsg;
|
||||
state.alert.content = content;
|
||||
state.alert.key = key;
|
||||
return state;
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (this.context.user) {
|
||||
this.context.navigate("/dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root pt-3">
|
||||
<Container>
|
||||
<Alert show={this.state.alert.show} variant="warning" onClose={() => this.setState((state) => { state.alert.show = false; return state; })} dismissible>
|
||||
<Alert.Heading>{this.state.alert.headerMsg}</Alert.Heading>
|
||||
{this.state.alert.content}
|
||||
</Alert>
|
||||
<Card style={{ width: "35rem" }}>
|
||||
<Card.Body>
|
||||
<Card.Title>Sign up!</Card.Title>
|
||||
<Card.Subtitle>Welcome to Sports Matcher! Already <Link to="/login">have an account</Link>?</Card.Subtitle>
|
||||
<Form onSubmit={this.registerUser}>
|
||||
<Form.Group className="mb-3" controlId="firstName">
|
||||
<Form.Label>First name</Form.Label>
|
||||
<Form.Control type="text" placeholder="Ex. John" onChange={this.setUserState} required />
|
||||
</Form.Group>
|
||||
<Form.Group className="mb-3" controlId="lastName">
|
||||
<Form.Label>Last name</Form.Label>
|
||||
<Form.Control type="text" placeholder="Ex. Smith" onChange={this.setUserState} required />
|
||||
</Form.Group>
|
||||
<Form.Group className="mb-3" controlId="email">
|
||||
<Form.Label>E-mail</Form.Label>
|
||||
<Form.Control type="email" placeholder="Ex. youremail@mail.com" onChange={this.setUserState} required />
|
||||
</Form.Group>
|
||||
<Form.Group className="mb-3" controlId="phone">
|
||||
<Form.Label>Phone number</Form.Label>
|
||||
<Form.Control type="text" placeholder="Ex. (123) 456-7890" onChange={this.setUserState} />
|
||||
</Form.Group>
|
||||
<Form.Group className="mb-3" controlId="password">
|
||||
<Form.Label>Password</Form.Label>
|
||||
<Form.Control type="password" placeholder="Enter password" onChange={this.setUserState} required />
|
||||
</Form.Group>
|
||||
<Button variant="primary" type="submit">
|
||||
Register!
|
||||
</Button>
|
||||
</Form>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
</Container>
|
||||
</div >
|
||||
);
|
||||
}
|
||||
}
|
42
sports-matcher/client/src/pages/Welcome.js
Normal file
@ -0,0 +1,42 @@
|
||||
import React from "react";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
import HomeCarousel from "../components/HomeCarousel";
|
||||
import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
|
||||
export default class Welcome extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
displayedMatches: [],
|
||||
};
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
await this.latestMatches();
|
||||
|
||||
}
|
||||
|
||||
async latestMatches() {
|
||||
let recentMatchesRes = await apiClient.get("/match/recent/15");
|
||||
if (recentMatchesRes.status === 200) {
|
||||
this.setState({ displayedMatches: recentMatchesRes.data.recent });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root">
|
||||
<HomeCarousel />
|
||||
<div className="text-center p-3 mt-2">
|
||||
<h2>Why?</h2>
|
||||
<p>Because you want to play the sports you love while meeting new friends!</p>
|
||||
{/* TODO: All this text should be expanded on. */}
|
||||
</div>
|
||||
<hr />
|
||||
<div className="p-4">
|
||||
<h2>Available Matches</h2>
|
||||
<MatchInfoCardDisplay recommendedmatches={this.state.displayedMatches} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
13
sports-matcher/client/src/reportWebVitals.js
Normal file
@ -0,0 +1,13 @@
|
||||
const reportWebVitals = onPerfEntry => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
5
sports-matcher/client/src/setupTests.js
Normal file
@ -0,0 +1,5 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import "@testing-library/jest-dom";
|
15
sports-matcher/client/src/styles/Admin.css
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
.MainTable {
|
||||
padding : 20px;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
padding: 21px;
|
||||
}
|
||||
|
||||
|
||||
.somespace {
|
||||
padding: 17px;
|
||||
}
|
||||
|
5
sports-matcher/client/src/styles/Dashboard.css
Normal file
@ -0,0 +1,5 @@
|
||||
.w-50{
|
||||
margin-top: 5%;
|
||||
margin-left: 25%;
|
||||
margin-right: 25%;
|
||||
}
|
16
sports-matcher/client/src/styles/Layout.css
Normal file
@ -0,0 +1,16 @@
|
||||
.page-root,
|
||||
main,
|
||||
#app,
|
||||
#root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
.horizontal-scroller{
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
}
|
5
sports-matcher/client/src/styles/extra.css
Normal file
@ -0,0 +1,5 @@
|
||||
.horizontal-scroller {
|
||||
overflow-x: scroll;
|
||||
padding-top: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
}
|
10
sports-matcher/client/src/utils/httpClients.js
Normal file
@ -0,0 +1,10 @@
|
||||
import axios from "axios";
|
||||
|
||||
export const apiClient = axios.create({
|
||||
baseURL: (process.env.REACT_APP_API_HOST || "") + "/api/",
|
||||
timeout: 5000,
|
||||
withCredentials: process.env.NODE_ENV === "development",
|
||||
validateStatus: function (status) {
|
||||
return status === 401 || status === 200 || status === 400 || status === 201;
|
||||
}
|
||||
});
|
24
sports-matcher/client/src/utils/strings.js
Normal file
@ -0,0 +1,24 @@
|
||||
export function grammaticalListString(items, max) {
|
||||
if (!items) return null;
|
||||
if (max < 1) return "";
|
||||
let built = "";
|
||||
|
||||
let index = 0;
|
||||
items.forEach(item => {
|
||||
if (index > max) {
|
||||
built += "and " + items.length + " more ";
|
||||
return;
|
||||
}
|
||||
built += item;
|
||||
if (index < items.length - 1) {
|
||||
built += ", ";
|
||||
}
|
||||
if (index == max - 1) {
|
||||
built += "and ";
|
||||
}
|
||||
|
||||
index += 1;
|
||||
});
|
||||
|
||||
return built;
|
||||
}
|
17
sports-matcher/scripts/build.py
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import shutil
|
||||
|
||||
DEST_DIR = os.path.abspath("../server/public/")
|
||||
BUILD_CMD = "react-scripts build"
|
||||
os.chdir(os.path.abspath(os.path.join(__file__, "../../client")))
|
||||
errorcode = os.system(BUILD_CMD)
|
||||
if (errorcode):
|
||||
print("There was an issue building the client via {}. See above log (exited with error code {}).".format(
|
||||
BUILD_CMD, errorcode))
|
||||
else:
|
||||
print("Received error code of 0. Proceeding with copying files to the public server directory.")
|
||||
|
||||
shutil.copytree("./build/", "../server/public/.", dirs_exist_ok=True)
|
||||
print("Completed copying built files to the public server directory \"{0}\".".format(
|
||||
DEST_DIR))
|
1
sports-matcher/scripts/start_mongo.bat
Normal file
@ -0,0 +1 @@
|
||||
mongod --dbpath ./server/mongo-data
|
3
sports-matcher/scripts/start_mongo.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
mongod --dbpath ../server/mongo-data
|
30
sports-matcher/server/.eslintrc.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"env": {
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
4
|
||||
],
|
||||
"linebreak-style": [
|
||||
"warn",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"double"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"no-unused-vars": "warn"
|
||||
}
|
||||
}
|
16
sports-matcher/server/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Current File",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
231
sports-matcher/server/controllers/matchController.js
Normal file
@ -0,0 +1,231 @@
|
||||
import express from "express";
|
||||
import { requireAdmin, requireAuthenticated } from "../middleware/authority.js";
|
||||
import { needDatabase } from "../middleware/database.js";
|
||||
import matchModel from "../schemas/matchModel.js";
|
||||
import sportModel from "../schemas/sportModel.js";
|
||||
import userModel from "../schemas/userModel.js";
|
||||
const MatchController = express.Router();
|
||||
|
||||
MatchController.get("/search/:sport", needDatabase, async (req, res) => {
|
||||
try {
|
||||
let sport = sportModel.findByName(req.params.sport);
|
||||
let query = matchModel.find({ sport: sport._id });
|
||||
query.where("when").gte(Date.now); // We don't want to return any results of matches that have already occurred.
|
||||
if (req.session.userId) query.where("publicity").gte(1).where("friends").in(req.session.userId);
|
||||
if (req.query.within) query.where("location").within({ center: req.query.location.split(","), radius: req.query.within });
|
||||
if (req.query.minDifficulty) query.where("difficulty").gte(req.query.minDifficulty);
|
||||
if (req.query.maxDifficulty) query.where("difficulty").lte(req.query.maxDifficulty);
|
||||
if (req.query.beforeDate) query.where("when").lte(req.query.beforeDate);
|
||||
|
||||
let queryResults = await query;
|
||||
res.send({ results: queryResults });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
|
||||
try {
|
||||
let limit = parseInt(req.params.limit);
|
||||
if (!req.params.limit) limit = 10;
|
||||
if (isNaN(limit)) {
|
||||
res.status(400).send("Limit parameter not a number.");
|
||||
return;
|
||||
}
|
||||
if (limit > 50) {
|
||||
res.status(400).send("Limit greater than maximum limit of 50.");
|
||||
return;
|
||||
}
|
||||
let recent = matchModel.find().where("publicity").gte(2);
|
||||
recent = await recent.sort({ createDate: -1 }).limit(limit).populate(["sport", "participants"]);
|
||||
res.status(200).send({ recent: recent });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/all", requireAdmin, async (req, res) => {
|
||||
try {
|
||||
const allmatches = await matchModel.find().populate("sport");
|
||||
res.status(200).send({ all: allmatches });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/recent/user/:limit", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
let user = req.user;
|
||||
let limit = parseInt(req.params.limit);
|
||||
if (!req.params.limit) limit = 10;
|
||||
if (isNaN(limit)) {
|
||||
res.status(400).send("Limit parameter not a number.");
|
||||
return;
|
||||
}
|
||||
let recent = await matchModel.find({ creator: user._id }).sort({ createDate: -1 }).limit(limit).populate(["sport", "participants"]);
|
||||
res.status(200).send({ recent: recent });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.post("/", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const userId = req.session.userId;
|
||||
const user = await userModel.findById(userId);
|
||||
const match = new matchModel({
|
||||
title: req.body.title,
|
||||
when: req.body.when,
|
||||
public: req.body.public,
|
||||
location: req.body.location,
|
||||
creator: userId,
|
||||
difficulty: req.body.difficulty,
|
||||
sport: await sportModel.findByName(req.body.sport),
|
||||
participants: [user._id]
|
||||
});
|
||||
if (!match.sport) {
|
||||
res.status(400).send("Invalid sport name provided.");
|
||||
return;
|
||||
}
|
||||
await match.save();
|
||||
user.createdMatches.push(match._id);
|
||||
user.participatingMatches.push(match._id);
|
||||
await user.save();
|
||||
res.status(201).send({ createdMatch: match });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Develop the error handling.
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.patch("/:id", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const match = await matchModel.findById(req.params.id);
|
||||
if (!match) {
|
||||
res.status(400).send("Invalid match ID provided.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.user._id !== match.creator && req.user.accessLevel < 3) {
|
||||
res.status(401).send("Not authorized.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body._id) {
|
||||
res.status(400).send("Cannot change ID of match.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.creator) {
|
||||
res.status(400).send("Cannot change creator of match.");
|
||||
return;
|
||||
}
|
||||
await match.updateOne(req.body);
|
||||
res.status(200).send({ updatedMatch: match });
|
||||
|
||||
} catch (error) {
|
||||
res.status(200).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.delete("/:id", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const match = await matchModel.findById(req.params.id);
|
||||
if (!match) {
|
||||
res.status(400).send("Invalid match ID provided.");
|
||||
return;
|
||||
}
|
||||
if (req.user._id !== match.creator && req.user.accessLevel < 3) {
|
||||
res.status(401).send("Not authorized.");
|
||||
return;
|
||||
}
|
||||
await match.deleteOne();
|
||||
res.status(200).send("Deleted.");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/:id", needDatabase, async (req, res) => {
|
||||
try {
|
||||
if (!req.params.id) {
|
||||
res.status(404).send("Id must be provided to retrieve match");
|
||||
return;
|
||||
}
|
||||
const match = await matchModel.findById(req.params.id).populate("sport");
|
||||
if (match) {
|
||||
res.status(200).send({ match: match });
|
||||
} else {
|
||||
res.status(404).send("Could not find match with ID: " + req.params.id);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Improve the error handling.
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/join/:id", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const match = await matchModel.findById(req.params.id);
|
||||
const user = req.user;
|
||||
if (!match) {
|
||||
res.status(400).send("Invalid match ID provided.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.participatingMatches.includes(match._id)) {
|
||||
res.status(400).send("Already participating in match.");
|
||||
return;
|
||||
}
|
||||
|
||||
match.participants.push(user._id);
|
||||
user.participatingMatches.push(match._id);
|
||||
|
||||
await match.save();
|
||||
await user.save();
|
||||
|
||||
res.status(200).send("Joined.");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
MatchController.get("/leave/:id", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const match = await matchModel.findById(req.params.id);
|
||||
const user = req.user;
|
||||
|
||||
if (!match) {
|
||||
res.status(400).send("Invalid match ID provided.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.participatingMatches.includes(match._id)) {
|
||||
res.status(400).send("Not part of match.");
|
||||
return;
|
||||
}
|
||||
|
||||
const userIndex = match.participants.indexOf(user._id);
|
||||
match.participants.splice(userIndex, 1);
|
||||
await match.save();
|
||||
|
||||
const matchIndex = user.participatingMatches.indexOf(match._id);
|
||||
user.participatingMatches.splice(matchIndex, 1);
|
||||
await user.save();
|
||||
|
||||
res.status(200).send("Left match.");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
export default MatchController;
|
115
sports-matcher/server/controllers/rentalController.js
Normal file
@ -0,0 +1,115 @@
|
||||
import express from "express";
|
||||
import { requireAuthenticated } from "../middleware/authority.js";
|
||||
import { needDatabase } from "../middleware/database.js";
|
||||
import rentalModel from "../schemas/rentalModel.js";
|
||||
import userModel from "../schemas/userModel.js";
|
||||
const rentalController = express.Router();
|
||||
|
||||
|
||||
rentalController.post("/", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const user = req.user;
|
||||
req.body.createDate = undefined;
|
||||
req.body.creator = user._id;
|
||||
const rental = new rentalModel(req.body);
|
||||
await rental.save();
|
||||
res.status(201).send({ createdRental: rental });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
rentalController.get("/:id", needDatabase, async (req, res) => {
|
||||
try {
|
||||
const rental = await rentalModel.findById(req.params.id).populate("creator");
|
||||
res.status(200).send({ rental: rental });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error");
|
||||
}
|
||||
});
|
||||
|
||||
rentalController.get("/recent/:limit?", needDatabase, async (req, res) => {
|
||||
try {
|
||||
let user = null;
|
||||
if (req.session.userId) {
|
||||
user = await userModel.findById(req.session.userId);
|
||||
}
|
||||
let limit = parseInt(req.params.limit);
|
||||
if (!req.params.limit) limit = 10;
|
||||
if (isNaN(limit)) {
|
||||
res.status(400).send("Limit parameter is not a number.");
|
||||
return;
|
||||
}
|
||||
if (isNaN(limit)) {
|
||||
res.status(400).send("Limit parameter not a number.");
|
||||
return;
|
||||
}
|
||||
if (limit > 50) {
|
||||
res.status(400).send("Limit greater than maximum limit of 50.");
|
||||
return;
|
||||
}
|
||||
let recent = null;
|
||||
if (user) {
|
||||
await user.populate("createdRentals");
|
||||
recent = user.createdRentals.slice(-limit);
|
||||
} else {
|
||||
recent = await rentalModel.find().limit(limit).sort({ createDate: -1 });
|
||||
}
|
||||
await recent.populate("members.$");
|
||||
res.status(200).send({ recent: recent });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
rentalController.patch("/:id", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const rental = await rentalModel.findById(req.params.id);
|
||||
if (!rental) {
|
||||
res.status(400).send("Invalid rental ID provided.");
|
||||
return;
|
||||
}
|
||||
if (req.body._id) {
|
||||
res.status(400).send("Cannot change ID of rental.");
|
||||
return;
|
||||
}
|
||||
if (req.body.creator) {
|
||||
res.status(400).send("Cannot change creator of rental.");
|
||||
return;
|
||||
}
|
||||
if (req.user._id !== rental.creator && req.user.accessLevel < 3) {
|
||||
res.status(401).send("Not authorized.");
|
||||
return;
|
||||
}
|
||||
await rental.updateOne(req.body);
|
||||
res.status(200).send({ updated: rental });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error.");
|
||||
}
|
||||
});
|
||||
|
||||
rentalController.delete("/:id", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const rental = await rentalModel.findById(req.params.id);
|
||||
if (!rental) {
|
||||
res.status(400).send("Invalid match ID provided.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.user._id !== rental.creator && req.user.accessLevel < 3) {
|
||||
res.status(401).send("Not authorized.");
|
||||
return;
|
||||
}
|
||||
await rental.deleteOne();
|
||||
res.status(200).send("Deleted.");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error");
|
||||
}
|
||||
});
|
||||
|
||||
export default rentalController;
|
48
sports-matcher/server/controllers/sportController.js
Normal file
@ -0,0 +1,48 @@
|
||||
import express from "express";
|
||||
import { requireAuthenticated } from "../middleware/authority.js";
|
||||
import { needDatabase } from "../middleware/database.js";
|
||||
import sportModel from "../schemas/sportModel.js";
|
||||
import userModel from "../schemas/userModel.js";
|
||||
|
||||
const SportController = express.Router();
|
||||
|
||||
SportController.post("/", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
const user = await userModel.findById(req.session.userId);
|
||||
try {
|
||||
if (user.accessLevel <= 2) {
|
||||
res.status(403).send("Insufficient privileges.");
|
||||
return;
|
||||
}
|
||||
const sport = new sportModel({
|
||||
name: req.body.name,
|
||||
maxPlayers: req.body.maxPlayers,
|
||||
minPlayers: req.body.minPlayers,
|
||||
description: req.body.description
|
||||
});
|
||||
await sport.save();
|
||||
res.status(201).send("Successfully created new sport.");
|
||||
} catch (error) {
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Add proper error checking here.
|
||||
}
|
||||
});
|
||||
|
||||
SportController.get("/:sportId", needDatabase, async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await sportModel.findById(req.params.sportId));
|
||||
} catch (error) {
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Add proper error checking here.
|
||||
}
|
||||
});
|
||||
|
||||
SportController.get("/", needDatabase, async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await sportModel.find());
|
||||
} catch (error) {
|
||||
res.status(500).send("Internal server error.");
|
||||
// TODO: Add proper error checking here.
|
||||
}
|
||||
});
|
||||
|
||||
export default SportController;
|
218
sports-matcher/server/controllers/userController.js
Normal file
@ -0,0 +1,218 @@
|
||||
import express from "express";
|
||||
import { requireAdmin, requireAuthenticated } from "../middleware/authority.js";
|
||||
import { needDatabase } from "../middleware/database.js";
|
||||
import userModel from "../schemas/userModel.js";
|
||||
import User from "../schemas/userModel.js";
|
||||
const UserController = express.Router();
|
||||
|
||||
UserController.post("/login", needDatabase, async (req, res) => {
|
||||
try {
|
||||
const email = req.body.email;
|
||||
const pwd = req.body.password;
|
||||
const user = await User.credentialsExist(email, pwd);
|
||||
if (!user) {
|
||||
res.sendStatus(401);
|
||||
return;
|
||||
} else {
|
||||
req.session.userId = user._id;
|
||||
req.session.email = user.email;
|
||||
user.password = undefined;
|
||||
res.status(200).send(user);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.name === "TypeError") {
|
||||
res.status(400).send("Missing required user info.");
|
||||
} else if (error.message === "Credentials do not exist.") {
|
||||
res.status(401).send("Credentials do not exist.");
|
||||
} else {
|
||||
console.error(error);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
res.status(500).send(error.toString());
|
||||
} else {
|
||||
res.status(500).send("Internal server error. This issue has been noted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/logout", requireAuthenticated, (req, res) => {
|
||||
req.session.destroy((err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
res.status(500).send(err.toString());
|
||||
} else {
|
||||
res.status(500).send("Internal server error. This issue has been noted.");
|
||||
}
|
||||
res.status(500).send("");
|
||||
} else {
|
||||
res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
UserController.get("/:id?", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
let user = null;
|
||||
if (req.params.id) {
|
||||
if (req.user.accessLevel > 2) {
|
||||
user = await userModel.findById(req.params.id);
|
||||
} else {
|
||||
res.status(401).send("Unauthorized.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
user = req.user;
|
||||
}
|
||||
user.password = undefined;
|
||||
res.status(200).send(user);
|
||||
});
|
||||
|
||||
|
||||
UserController.patch("/:id?", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
let user = null;
|
||||
if (req.params.id) {
|
||||
if (req.user.accessLevel > 2) {
|
||||
user = await userModel.findById(req.params.id);
|
||||
} else {
|
||||
res.status(401).send("Unauthorized.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
user = req.user;
|
||||
}
|
||||
if (req.body._id) {
|
||||
res.status(400).send("Cannot change user ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.createdMatches) {
|
||||
res.status(400).send("Cannot directly change the list of created matches.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.password) {
|
||||
res.status(400).send("Cannot directly change user password.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.participatingMatches) {
|
||||
res.status(400).send("Cannot directly change the list of participating matches.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.joinDate) {
|
||||
res.status(400).send("Cannot change the join date.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.accessLevel && req.user.accessLevel < 3) {
|
||||
res.status(401).send("Unauthorized to change the access level of this user.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.suspend && req.user.accessLevel < 3) {
|
||||
res.status(401).send("Unauthorized to change the accounts disabled date. ");
|
||||
return;
|
||||
}
|
||||
|
||||
await user.updateOne(req.body);
|
||||
res.status(200).send("Updated.");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/all", requireAdmin, async (req, res) => {
|
||||
try {
|
||||
let all = await userModel.find();
|
||||
res.status(200).send({ all: all });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/all/active", requireAdmin, async (req, res) => {
|
||||
try {
|
||||
let active = await userModel.find().where("suspend").lt(Date.now());
|
||||
res.status(200).send({ active: active });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error");
|
||||
}
|
||||
});
|
||||
|
||||
UserController.get("/all/suspended", requireAuthenticated, async (req, res) => {
|
||||
try {
|
||||
let suspended = await userModel.find().where("suspend").gte(Date.now());
|
||||
res.status(200).send({ suspended: suspended });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal server error");
|
||||
}
|
||||
});
|
||||
|
||||
/* TODO: Implement middleware for removing users.
|
||||
|
||||
UserController.delete("/:id?", needDatabase, requireAuthenticated, async (req, res) => {
|
||||
let user = null;
|
||||
if (req.params.id) {
|
||||
if (req.user.accessLevel > 2) {
|
||||
user = await userModel.findById(req.params.id);
|
||||
} else {
|
||||
res.status(401).send("Unauthorized.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
user = req.user;
|
||||
}
|
||||
|
||||
await user.deleteOne();
|
||||
res.status(200).send("Deleted user.");
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
UserController.post("/", needDatabase, async (req, res) => {
|
||||
try {
|
||||
const data = {
|
||||
email: req.body.email,
|
||||
firstName: req.body.firstName,
|
||||
lastName: req.body.lastName,
|
||||
phone: req.body.phone,
|
||||
password: req.body.password,
|
||||
};
|
||||
|
||||
let createdUser = new User(data);
|
||||
await createdUser.save();
|
||||
res.sendStatus(201);
|
||||
return;
|
||||
} catch (err) {
|
||||
if (err.name === "TypeError" || err.name === "ValidationError") {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.error(err);
|
||||
res.status(400).send(err.toString());
|
||||
} else {
|
||||
res.status(400).send("Missing required user info.");
|
||||
}
|
||||
} else if (err.name === "MongoServerError" && err.message.startsWith("E11000")) {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.error(err);
|
||||
res.status(409).send(err.toString());
|
||||
} else {
|
||||
res.status(409).send("User already exists.");
|
||||
}
|
||||
} else {
|
||||
console.error(err);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
res.status(500).send(err.toString());
|
||||
} else {
|
||||
res.status(500).send("Internal server error. This issue has been noted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default UserController;
|
2
sports-matcher/server/database/mongoose.js
Normal file
@ -0,0 +1,2 @@
|
||||
export const mongooseDbName = process.env.DB_NAME || "sm_db";
|
||||
export const mongoURI = process.env.MONGODB_URI || "mongodb://127.0.0.1:27017";
|
52
sports-matcher/server/middleware/authority.js
Normal file
@ -0,0 +1,52 @@
|
||||
import MongoStore from "connect-mongo";
|
||||
import session from "express-session";
|
||||
import { mongooseDbName, mongoURI } from "../database/mongoose.js";
|
||||
import userModel from "../schemas/userModel.js";
|
||||
import { checkDatabaseConnection } from "./database.js";
|
||||
const sessionConf = {
|
||||
secret: process.env.SESSION_SECRET || "super duper secret string.",
|
||||
cookie: {
|
||||
expires: process.env.SESSION_TIMEOUT || 300000,
|
||||
httpOnly: true,
|
||||
},
|
||||
saveUninitialized: false,
|
||||
resave: false,
|
||||
};
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
sessionConf.cookie.secure = true;
|
||||
sessionConf.store = MongoStore.create({ mongoUrl: mongoURI, dbName: mongooseDbName });
|
||||
}
|
||||
export const userSession = session(sessionConf);
|
||||
|
||||
export async function requireAuthenticated(req, res, next) {
|
||||
if (!checkDatabaseConnection()) {
|
||||
req.status(500).send("Internal server error.");
|
||||
return;
|
||||
}
|
||||
if (req.session.userId) {
|
||||
req.user = await userModel.findById(req.session.userId);
|
||||
next();
|
||||
} else {
|
||||
res.status(401).send("Not authorized.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function requireAdmin(req, res, next) {
|
||||
if (!checkDatabaseConnection()) {
|
||||
req.status(500).send("Internal server error.");
|
||||
return;
|
||||
}
|
||||
if (req.session.userId) {
|
||||
req.user = await userModel.findById(req.session.userId);
|
||||
if (req.user.accessLevel < 3) {
|
||||
res.status(401).send("Not authorized");
|
||||
return;
|
||||
}
|
||||
next();
|
||||
} else {
|
||||
res.status(401).send("Not authorized.");
|
||||
return;
|
||||
}
|
||||
}
|
13
sports-matcher/server/middleware/database.js
Normal file
@ -0,0 +1,13 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
export function needDatabase(req, res, next) {
|
||||
if (!checkDatabaseConnection()) {
|
||||
res.status(500).send("Internal server error: Database connection faulty.");
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
export function checkDatabaseConnection() {
|
||||
return mongoose.connection.readyState == 1;
|
||||
}
|