Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Progark gruppe 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Ingebrigt Ørstad
Progark gruppe 3
Commits
f90e1cb0
Commit
f90e1cb0
authored
5 years ago
by
Tobias Ørstad
Browse files
Options
Downloads
Patches
Plain Diff
Update method for joining tournaments. Issue
#28
parent
ef8c9ae5
Branches
Branches containing commit
No related tags found
1 merge request
!17
WIP: Resolve "Join tournament"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/api/tournament.js
+16
-28
16 additions, 28 deletions
backend/api/tournament.js
backend/index.js
+1
-1
1 addition, 1 deletion
backend/index.js
with
17 additions
and
29 deletions
backend/api/tournament.js
+
16
−
28
View file @
f90e1cb0
...
@@ -3,8 +3,8 @@ const router = express.Router();
...
@@ -3,8 +3,8 @@ const router = express.Router();
const
mongo
=
require
(
"
mongodb
"
);
const
mongo
=
require
(
"
mongodb
"
);
const
MongoClient
=
mongo
.
MongoClient
;
const
MongoClient
=
mongo
.
MongoClient
;
const
connectionUrl
=
process
.
env
.
MONGO_CONNECTION_STRING
;
const
connectionUrl
=
process
.
env
.
MONGO_CONNECTION_STRING
;
/*
router.post("/
new/:host/:games/:name/:tpr/:players/:rpg
", (req, res) => {
router
.
post
(
"
/
join
"
,
(
req
,
res
)
=>
{
MongoClient
.
connect
(
MongoClient
.
connect
(
connectionUrl
,
connectionUrl
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
},
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
},
...
@@ -15,37 +15,25 @@ router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
...
@@ -15,37 +15,25 @@ router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
return
;
return
;
}
}
const games = req.params.games.split("&");
const
db
=
client
.
db
(
"
gameWare
"
);
const
db
=
client
.
db
(
"
gameWare
"
);
const
collection
=
"
tournaments
"
;
const
collection
=
"
tournaments
"
;
const tournamentid;
db.collection(collection).insertOne(
db
.
collection
(
collection
)
{
.
find
({
gameid: req.body.gameid,
$expr
:
{
$lt
:
[
"
$maxPlayers
"
,
"
$players.length
"
]
}
players: [req.body.userid],
})
games: "todo",
.
toArray
((
err
,
result
)
=>
{
name: req.body.name,
timePerRound: parseInt(req.body.timePerRound),
maxPlayers: parseInt(req.body.maxPlayers),
roundsPerGame: parseInt(req.body.roundsPerGame),
currentRound: 1,
dateCreated: new Date()
},
(err, result) => {
if
(
err
)
{
if
(
err
)
{
res.sendStatus(500); // Internal server error
res
.
sendStatus
(
500
);
console
.
log
(
err
);
return
;
return
;
}
}
tournamentid = result._id;
res
.
json
(
result
);
});
db
.
collection
(
"
rounds
"
).
insertOne
({});
}
}
);
);
db.collection("rounds").insertOne(
});
{
}
// Export API routes
)
module
.
exports
=
router
;
}
);
});*/
This diff is collapsed.
Click to expand it.
backend/index.js
+
1
−
1
View file @
f90e1cb0
...
@@ -13,7 +13,7 @@ app.disable("x-powered-by"); // Minium security
...
@@ -13,7 +13,7 @@ app.disable("x-powered-by"); // Minium security
app
.
use
(
"
/api/games
"
,
require
(
"
./api/games
"
));
// Use games.js for route /api/games
app
.
use
(
"
/api/games
"
,
require
(
"
./api/games
"
));
// Use games.js for route /api/games
app
.
use
(
"
/api/highscores
"
,
require
(
"
./api/highscores
"
));
app
.
use
(
"
/api/highscores
"
,
require
(
"
./api/highscores
"
));
app
.
use
(
"
/api/players
"
,
require
(
"
./api/players
"
));
app
.
use
(
"
/api/players
"
,
require
(
"
./api/players
"
));
//
app.use("/api/tournament", require("./api/tournament"));
app
.
use
(
"
/api/tournament
"
,
require
(
"
./api/tournament
"
));
// Default route
// Default route
app
.
get
(
"
/api
"
,
(
req
,
res
)
=>
{
app
.
get
(
"
/api
"
,
(
req
,
res
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment