Update record

This commit is contained in:
KGrzeg 2021-10-17 23:00:29 +02:00
parent 6843b76ebf
commit a38072214e
3 changed files with 27 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import cors from 'cors'
import auth from './Auth.js'
import db from './Database.js'
import jg from './JusticeGuard'
const protect = (req, res, next) => {
const authHeader = req.headers.authorization;
@ -75,6 +76,14 @@ app.post("/login", neededArguments(['key']), async (req, res) => {
res.json(user)
})
app.post("/record", neededArguments(['points', 'shoots', 'time']), jg, async (req, res) => {
db.updateRecord(req.user.name, req.body.points)
res.json({
status: "ok"
})
})
app.use(function (err, req, res, next) {
if (err.name === 'UnauthorizedError') {
res.status(401).send('invalid token...');