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

you can now send parameters in body

parent c857d223
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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`.

## 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>
Returns the current voting status for the current map.<br>
+2 −2
Original line number Diff line number Diff line
@@ -7,8 +7,8 @@ const path = require('path'),
 */
module.exports = function(app, sql, token, errorHandler) {
    app.get('/'+scriptName, function(req, res) {
        const mapId = req.query.map,
            player = req.query.player;
        const mapId = req.query.map || req.body.map,
            player = req.query.player || req.body.player;
        if (!mapId) {
            return errorHandler(res, 400, 'Missing map id');
        }
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ const path = require('path'),
 */
module.exports = function(app, sql, token, errorHandler) {
    app.get('/'+scriptName, function(req, res) {
        const mapId = req.query.map;
        const mapId = req.query.map || req.body.map;
        if (!mapId) {
            return errorHandler(res, 400, 'Missing map id');
        }
+3 −3
Original line number Diff line number Diff line
@@ -10,9 +10,9 @@ const path = require('path'),
module.exports = function(app, sql, tokenCheck, errorHandler) {
    app.post('/'+scriptName, function(req, res) {
        //tokenCheck(req, res, sql, ()=>{
            const mapId = req.query.map,
                player = req.query.player,
                vote = Number(req.query.vote);
            const mapId = req.query.map || req.body.map,
                player = req.query.player || req.body.player,
                vote = Number(req.query.vote || req.body.vote);
            if (!mapId) return errorHandler(res, 400, 'Missing map id');
            if (!player) return errorHandler(res, 400, 'Missing player login');
            if (!vote) return errorHandler(res, 400, 'Missing vote');