fix serverId param
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { NextFunction, Router } from 'express'
|
import { NextFunction, Router } from 'express'
|
||||||
import expressBasicAuth from 'express-basic-auth'
|
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 register from './register'
|
||||||
import { CreateKillRecord, CheckServerToken } from '../db/db'
|
import { CreateKillRecord, CheckServerToken } from '../db/db'
|
||||||
import { validateErrors } from '../common'
|
import { validateErrors } from '../common'
|
||||||
@@ -58,6 +58,7 @@ router.post('/:serverId/kill', (req, res, next) => {
|
|||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/:serverId/kill',
|
'/:serverId/kill',
|
||||||
|
param('serverId').exists().toInt().isInt(),
|
||||||
body([
|
body([
|
||||||
'attacker_current_weapon_mods',
|
'attacker_current_weapon_mods',
|
||||||
'attacker_weapon_1_mods',
|
'attacker_weapon_1_mods',
|
||||||
@@ -149,13 +150,13 @@ router.post(
|
|||||||
cause_of_death,
|
cause_of_death,
|
||||||
distance
|
distance
|
||||||
} = req.body
|
} = req.body
|
||||||
if (!req.query.serverId) {
|
if (!req.params.serverId) {
|
||||||
res.status(500).send('serverId cannot be undefined')
|
res.status(500).send('serverId cannot be undefined')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
CreateKillRecord({
|
CreateKillRecord({
|
||||||
killstat_version,
|
killstat_version,
|
||||||
server: Number(req.query.serverId),
|
server: Number(req.params.serverId),
|
||||||
match_id,
|
match_id,
|
||||||
game_mode,
|
game_mode,
|
||||||
map,
|
map,
|
||||||
@@ -192,7 +193,7 @@ router.post(
|
|||||||
res.sendStatus(201)
|
res.sendStatus(201)
|
||||||
console.log(
|
console.log(
|
||||||
`[${Date.now().toLocaleString()}] Kill submitted for server ${
|
`[${Date.now().toLocaleString()}] Kill submitted for server ${
|
||||||
req.query.serverId
|
req.params.serverId
|
||||||
}, ${attacker_name} killed ${victim_name}`
|
}, ${attacker_name} killed ${victim_name}`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user