Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Voting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Voting
Commits
799203d6
Commit
799203d6
authored
Aug 23, 2021
by
Matthieu - Greep
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tmio API player check
parent
09f1927e
Pipeline
#458
passed with stage
in 1 minute and 22 seconds
Changes
3
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
983 additions
and
105 deletions
+983
-105
package-lock.json
package-lock.json
+970
-101
package.json
package.json
+2
-1
setVote.js
route/setVote.js
+11
-3
No files found.
package-lock.json
View file @
799203d6
This diff is collapsed.
Click to expand it.
package.json
View file @
799203d6
...
...
@@ -18,7 +18,8 @@
"
dotenv
"
:
"
^10.0.0
"
,
"
express
"
:
"
^4.17.1
"
,
"
morgan
"
:
"
^1.10.0
"
,
"
mysql
"
:
"
^2.18.1
"
"
mysql
"
:
"
^2.18.1
"
,
"
trackmania.io
"
:
"
^2.4.0
"
},
"devDependencies"
:
{
"
eslint
"
:
"
^7.32.0
"
,
...
...
route/setVote.js
View file @
799203d6
const
path
=
require
(
'
path
'
),
scriptName
=
path
.
basename
(
__filename
).
replace
(
/
\.
js$/i
,
''
);
scriptName
=
path
.
basename
(
__filename
).
replace
(
/
\.
js$/i
,
''
),
tmio
=
require
(
'
trackmania.io
'
),
tmioPlayer
=
new
tmio
.
Players
();
/**
* @param {import('express').Express} app
...
...
@@ -17,9 +19,15 @@ module.exports = function(app, sql, tokenCheck, errorHandler) {
if
(
isNaN
(
vote
))
return
errorHandler
(
res
,
400
,
'
Invalid vote
'
);
if
(
vote
<
0
||
vote
>
100
)
return
errorHandler
(
res
,
400
,
'
Vote must be between 0 and 100
'
);
//TODO: check if player exists (tmio API check)
// check if player exists (tmio API check)
tmioPlayer
.
player
(
player
).
then
((
playerData
)
=>
{
if
(
playerData
.
error
)
return
errorHandler
(
res
,
400
,
playerData
.
error
);
});
//TODO: check if map exists (tmio API check)
// check if map exists (tmio API check)
tmio
.
map
(
mapId
).
then
((
mapData
)
=>
{
if
(
mapData
.
error
)
return
errorHandler
(
res
,
400
,
mapData
.
error
);
});
sql
.
query
(
'
SELECT * FROM votes WHERE map = ? AND player = ?
'
,
[
mapId
,
player
],
(
err
,
sqlRes
)
=>
{
if
(
err
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment