commit
This commit is contained in:
parent
4825be45e1
commit
0bac40a72f
8 changed files with 256 additions and 16 deletions
23
api/v1/games/getall.js
Normal file
23
api/v1/games/getall.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const express = require('express');
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
const {getGames} = require("../../../libs/mysql.js")
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
const {token} = req.body;
|
||||
|
||||
let user;
|
||||
|
||||
try {
|
||||
user = jwt.verify(token, process.env.JWTSecret);
|
||||
} catch {
|
||||
return res.status(500).send({error: "invalid token"});
|
||||
}
|
||||
|
||||
const games = await getGames();
|
||||
res.status(200).send(games);
|
||||
});
|
||||
|
||||
module.exports = router;
|
Loading…
Add table
Add a link
Reference in a new issue