commit
This commit is contained in:
parent
dc429fe9ea
commit
e1470db521
1 changed files with 0 additions and 0 deletions
|
@ -1,30 +0,0 @@
|
|||
const express = require('express');
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
const {getHelpers} = require("../../../libs/mysql.js")
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
const {token, gameid} = req.body;
|
||||
|
||||
if (!token) {
|
||||
return res.status(400).send({error: "invalid token"});
|
||||
}
|
||||
|
||||
try {
|
||||
jwt.verify(token, process.env.JWTSecret);
|
||||
} catch {
|
||||
return res.status(400).send({error: "invalid token"});
|
||||
}
|
||||
|
||||
const helpers = await getHelpers(gameid)
|
||||
|
||||
if (!helpers[0]) {
|
||||
return res.status(400).send({error: "this game doesn't exist in the data base"})
|
||||
};
|
||||
|
||||
res.status(200).send(JSON.parse(helpers[0]));
|
||||
});
|
||||
|
||||
module.exports = router;
|
Loading…
Add table
Add a link
Reference in a new issue