fix serverId param

This commit is contained in:
2023-03-16 10:00:05 +01:00
parent e90b4068ff
commit 4578f3cfcd
+5 -4
View File
@@ -1,6 +1,6 @@
import { NextFunction, Router } from 'express'
import expressBasicAuth from 'express-basic-auth'
import { body, header, query } from 'express-validator'
import { body, header, param } from 'express-validator'
import register from './register'
import { CreateKillRecord, CheckServerToken } from '../db/db'
import { validateErrors } from '../common'
@@ -58,6 +58,7 @@ router.post('/:serverId/kill', (req, res, next) => {
router.post(
'/:serverId/kill',
param('serverId').exists().toInt().isInt(),
body([
'attacker_current_weapon_mods',
'attacker_weapon_1_mods',
@@ -149,13 +150,13 @@ router.post(
cause_of_death,
distance
} = req.body
if (!req.query.serverId) {
if (!req.params.serverId) {
res.status(500).send('serverId cannot be undefined')
return
}
CreateKillRecord({
killstat_version,
server: Number(req.query.serverId),
server: Number(req.params.serverId),
match_id,
game_mode,
map,
@@ -192,7 +193,7 @@ router.post(
res.sendStatus(201)
console.log(
`[${Date.now().toLocaleString()}] Kill submitted for server ${
req.query.serverId
req.params.serverId
}, ${attacker_name} killed ${victim_name}`
)
})