Commit f4341312 authored by Matthieu - Greep's avatar Matthieu - Greep

you can now send parameters in body

parent c857d223
Pipeline #461 passed with stage
in 50 seconds
...@@ -9,7 +9,7 @@ The client can connect to the socket server via `willers.digital` on port `3201` ...@@ -9,7 +9,7 @@ The client can connect to the socket server via `willers.digital` on port `3201`
If you just want to call the REST-Server you can do it with: `https://tm-voting.willers.digital`. If you just want to call the REST-Server you can do it with: `https://tm-voting.willers.digital`.
## REST Services ## REST Services
**All parameters MUST be done in the url query `/getVotes?map=blah`** **All parameters can be done in the url query `/getVotes?map=blah` or in the Body you sent in a JSON format `{"map":"blah"}`**
**GET /getVotes**<br> **GET /getVotes**<br>
Returns the current voting status for the current map.<br> Returns the current voting status for the current map.<br>
......
...@@ -7,8 +7,8 @@ const path = require('path'), ...@@ -7,8 +7,8 @@ const path = require('path'),
*/ */
module.exports = function(app, sql, token, errorHandler) { module.exports = function(app, sql, token, errorHandler) {
app.get('/'+scriptName, function(req, res) { app.get('/'+scriptName, function(req, res) {
const mapId = req.query.map, const mapId = req.query.map || req.body.map,
player = req.query.player; player = req.query.player || req.body.player;
if (!mapId) { if (!mapId) {
return errorHandler(res, 400, 'Missing map id'); return errorHandler(res, 400, 'Missing map id');
} }
......
...@@ -7,7 +7,7 @@ const path = require('path'), ...@@ -7,7 +7,7 @@ const path = require('path'),
*/ */
module.exports = function(app, sql, token, errorHandler) { module.exports = function(app, sql, token, errorHandler) {
app.get('/'+scriptName, function(req, res) { app.get('/'+scriptName, function(req, res) {
const mapId = req.query.map; const mapId = req.query.map || req.body.map;
if (!mapId) { if (!mapId) {
return errorHandler(res, 400, 'Missing map id'); return errorHandler(res, 400, 'Missing map id');
} }
......
...@@ -10,9 +10,9 @@ const path = require('path'), ...@@ -10,9 +10,9 @@ const path = require('path'),
module.exports = function(app, sql, tokenCheck, errorHandler) { module.exports = function(app, sql, tokenCheck, errorHandler) {
app.post('/'+scriptName, function(req, res) { app.post('/'+scriptName, function(req, res) {
//tokenCheck(req, res, sql, ()=>{ //tokenCheck(req, res, sql, ()=>{
const mapId = req.query.map, const mapId = req.query.map || req.body.map,
player = req.query.player, player = req.query.player || req.body.player,
vote = Number(req.query.vote); vote = Number(req.query.vote || req.body.vote);
if (!mapId) return errorHandler(res, 400, 'Missing map id'); if (!mapId) return errorHandler(res, 400, 'Missing map id');
if (!player) return errorHandler(res, 400, 'Missing player login'); if (!player) return errorHandler(res, 400, 'Missing player login');
if (!vote) return errorHandler(res, 400, 'Missing vote'); if (!vote) return errorHandler(res, 400, 'Missing vote');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment