@@ -9,8 +9,8 @@ const app = express();
9
9
10
10
mongoose
11
11
. connect (
12
- // "mongodb://localhost:27017/myapp"
13
- "mongodb://ladder:YnwLdH8guBV9EOam@cluster0-shard-00-00-cvuiq.mongodb.net:27017,cluster0-shard-00-01-cvuiq.mongodb.net:27017,cluster0-shard-00-02-cvuiq.mongodb.net:27017/myLadder?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true&w=majority"
12
+ "mongodb://localhost:27017/myapp"
13
+ // "mongodb://ladder:YnwLdH8guBV9EOam@cluster0-shard-00-00-cvuiq.mongodb.net:27017,cluster0-shard-00-01-cvuiq.mongodb.net:27017,cluster0-shard-00-02-cvuiq.mongodb.net:27017/myLadder?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true&w=majority"
14
14
)
15
15
. then ( ( ) => {
16
16
console . log ( "Connected to database!" ) ;
@@ -58,16 +58,16 @@ function predicateBy(prop) {
58
58
// Squash Data
59
59
app . get ( '/api/table/squash' , ( req , res , next ) => {
60
60
const squashData = [ ] ;
61
- Player . find ( ) . then ( documents => {
61
+ Player . find ( { preferred : { $regex : "squash" } } ) . then ( documents => {
62
62
for ( let i = 0 ; i < documents . length ; i ++ ) {
63
63
squashData . push ( {
64
64
id : documents [ i ] [ "_id" ] ,
65
65
rank : null ,
66
66
username : documents [ i ] [ "name" ] ,
67
67
points : documents [ i ] [ "squash_score" ] ,
68
68
category : documents [ i ] [ "category" ] ,
69
- matchPlayed : documents [ i ] [ ' match_played_squash' ] ,
70
- matchWon : documents [ i ] [ ' match_won_squash' ]
69
+ matchPlayed : documents [ i ] [ " match_played_squash" ] ,
70
+ matchWon : documents [ i ] [ " match_won_squash" ]
71
71
} ) ;
72
72
}
73
73
squashData . sort ( predicateBy ( "points" ) ) ;
@@ -82,7 +82,7 @@ app.get('/api/table/squash', (req, res, next) => {
82
82
// Table Tennis Data
83
83
app . get ( '/api/table/tt' , ( req , res , next ) => {
84
84
const ttData = [ ] ;
85
- Player . find ( ) . then ( documents => {
85
+ Player . find ( { preferred : { $regex : "tt" } } ) . then ( documents => {
86
86
for ( let i = 0 ; i < documents . length ; i ++ ) {
87
87
ttData . push ( {
88
88
id : documents [ i ] [ "_id" ] ,
@@ -106,7 +106,7 @@ app.get('/api/table/tt', (req, res, next) => {
106
106
// Lawn Tennis Data
107
107
app . get ( '/api/table/tennis' , ( req , res , next ) => {
108
108
const tennisData = [ ] ;
109
- Player . find ( ) . then ( documents => {
109
+ Player . find ( { preferred : { $regex : "tennis" } } ) . then ( documents => {
110
110
for ( let i = 0 ; i < documents . length ; i ++ ) {
111
111
tennisData . push ( {
112
112
id : documents [ i ] [ "_id" ] ,
@@ -131,7 +131,7 @@ app.get('/api/table/tennis', (req, res, next) => {
131
131
app . get ( '/api/table/badminton' , ( req , res , next ) => {
132
132
133
133
const badmintonData = [ ] ;
134
- Player . find ( ) . then ( documents => {
134
+ Player . find ( { preferred : { $regex : "badminton" } } ) . then ( documents => {
135
135
for ( let i = 0 ; i < documents . length ; i ++ ) {
136
136
badmintonData . push ( {
137
137
id : documents [ i ] [ "_id" ] ,
@@ -713,7 +713,7 @@ app.post("/api/login", (req, res, next) => {
713
713
}
714
714
const token = jwt . sign (
715
715
{ roll : fetchedPlayer . roll , playerId : fetchedPlayer . _id } ,
716
- process . env . JWT_KEY
716
+ 'harsh_is_god_he_is_invincible'
717
717
) ;
718
718
res . status ( 200 ) . json ( {
719
719
token : token ,
0 commit comments