var express = require('express');
var Global = require('../global');
var search = require('../commands/search');

var router = express.Router();

router.get('/*', function(req, res) {
    var response = '';
    var arg = req.body.text;
console.log(req.body); //TODO delete
console.log(req.body.token); //TODO delete
    //validate token
    if(req.body.token === Global.authToken) {
        switch(req.body.command) {
            case '/searchin':
                response = search(arg, res);
                break;

            default:
            res.status('500');
            res.json({
                text: 'Unknown command'
            });
        }
    } else {
        res.status('403');
        res.json({
            text: 'Invalid token'
        });
    }
});

router.post('/*', function(req, res) {
    res.status('405');
    res.json({
        text: 'Method not allowed'
    });
});

module.exports = router;

var express = require('express');
var Global = require('../global');
var search = require('../commands/search');

var router = express.Router();

router.get('/*', function(req, res) {
    var response = '';
    var arg = req.query.text;
console.log(req.query); //TODO delete
console.log(req.query.token); //TODO delete
    //validate token
    if(req.query.token === Global.authToken) {
        switch(req.query.command) {
            case '/searchin':
                response = search(arg, res);
                break;

            default:
            res.status('500');
            res.json({
                text: 'Unknown command'
            });
        }
    } else {
        res.status('403');
        res.json({
            text: 'Invalid token'
        });
    }
});

router.post('/*', function(req, res) {
    res.status('405');
    res.json({
        text: 'Method not allowed'
    });
});

module.exports = router;

Switch back to using query instead of body
Switch back to using query instead of body
