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
35ed2b61
Commit
35ed2b61
authored
5 years ago
by
Tobias Ørstad
Browse files
Options
Downloads
Patches
Plain Diff
Progress on creating new tournament. Issue
#7
parent
c0362c96
No related branches found
No related tags found
3 merge requests
!20
Dev
,
!18
dev into fetch-tournament.
,
!11
Resolve "Post tournament"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/api/tournament.js
+27
-8
27 additions, 8 deletions
backend/api/tournament.js
backend/index.js
+1
-1
1 addition, 1 deletion
backend/index.js
with
28 additions
and
9 deletions
backend/api/tournament.js
+
27
−
8
View file @
35ed2b61
...
@@ -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
(
"
/new
"
,
(
req
,
res
)
=>
{
MongoClient
.
connect
(
MongoClient
.
connect
(
connectionUrl
,
connectionUrl
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
},
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
},
...
@@ -19,19 +19,20 @@ router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
...
@@ -19,19 +19,20 @@ router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
const
db
=
client
.
db
(
"
gameWare
"
);
const
db
=
client
.
db
(
"
gameWare
"
);
const
collection
=
"
tournaments
"
;
const
collection
=
"
tournaments
"
;
const tournamentid;
let
tournamentid
;
const
tournamentdate
=
new
Date
();
db
.
collection
(
collection
).
insertOne
(
db
.
collection
(
collection
).
insertOne
(
{
{
gameid
:
req
.
body
.
gameid
,
gameid
:
req
.
body
.
gameid
,
players
:
[
req
.
body
.
userid
],
players
:
[
req
.
body
.
userid
],
games:
"todo"
,
games
:
req
.
body
.
games
,
name
:
req
.
body
.
name
,
name
:
req
.
body
.
name
,
timePerRound
:
parseInt
(
req
.
body
.
timePerRound
),
timePerRound
:
parseInt
(
req
.
body
.
timePerRound
),
maxPlayers
:
parseInt
(
req
.
body
.
maxPlayers
),
maxPlayers
:
parseInt
(
req
.
body
.
maxPlayers
),
roundsPerGame
:
parseInt
(
req
.
body
.
roundsPerGame
),
roundsPerGame
:
parseInt
(
req
.
body
.
roundsPerGame
),
currentRound
:
1
,
currentRound
:
1
,
dateCreated:
new D
ate
()
dateCreated
:
tournamentd
ate
},
},
(
err
,
result
)
=>
{
(
err
,
result
)
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -41,11 +42,29 @@ router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
...
@@ -41,11 +42,29 @@ router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
tournamentid
=
result
.
_id
;
tournamentid
=
result
.
_id
;
}
}
);
);
tournamentdate
.
setTime
(
tournamentdate
.
getTime
()
+
req
.
body
.
timePerRound
*
60
*
60
*
1000
);
db
.
collection
(
"
rounds
"
).
insertOne
(
db
.
collection
(
"
rounds
"
).
insertOne
(
{
{
tournamentId
:
tournamentid
,
playerId
:
req
.
body
.
userid
,
gameId
:
req
.
body
.
game
.
get
(
0
),
scoreValue
:
0
,
roundNr
:
1
,
hasPlayed
:
false
,
deadlineDate
:
tournamentdate
},
err
=>
{
if
(
err
)
{
res
.
sendStatus
(
500
);
// Internal server error
return
;
}
}
)
res
.
json
(
result
);
}
}
);
);
});*/
}
);
});
module
.
exports
=
router
;
This diff is collapsed.
Click to expand it.
backend/index.js
+
1
−
1
View file @
35ed2b61
...
@@ -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