Update record
This commit is contained in:
parent
6843b76ebf
commit
a38072214e
3 changed files with 27 additions and 2 deletions
|
|
@ -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...');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue