eslint format

This commit is contained in:
2023-09-06 14:08:26 +02:00
parent 0ad5946246
commit 9b58d2141e
+46 -44
View File
@@ -1,57 +1,59 @@
import { RequestHandler, Request } from "express"; import { type RequestHandler, type Request } from 'express'
import typia from "typia"; import type typia from 'typia'
type WeaponKillData = { interface WeaponKillData {
id: string; id: string
mods: number; mods: number
}; }
export type LoadoutKillData = { export interface LoadoutKillData {
ordnance: WeaponKillData | undefined; ordnance: WeaponKillData | undefined
secondary: WeaponKillData | undefined; secondary: WeaponKillData | undefined
primary: WeaponKillData | undefined; primary: WeaponKillData | undefined
tactical: WeaponKillData | undefined; tactical: WeaponKillData | undefined
anti_titan: WeaponKillData | undefined; anti_titan: WeaponKillData | undefined
passive1:string | undefined; passive1: string | undefined
passive2:string | undefined; passive2: string | undefined
titan: string | undefined; titan: string | undefined
}; }
type PlayerKillData = { interface PlayerKillData {
velocity: number; velocity: number
name: string; name: string
loadout: LoadoutKillData; loadout: LoadoutKillData
current_weapon: WeaponKillData; current_weapon: WeaponKillData
state: string; state: string
id: string; id: string
cloaked: boolean; cloaked: boolean
}; }
export type MatchData = { export interface MatchData {
server_name: string; server_name: string
game_map: string; game_map: string
gamemode: string; gamemode: string
air_accel: boolean; air_accel: boolean
}; }
export type KillData = { export interface KillData {
game_time: number; game_time: number
player_count: number; player_count: number
match_id: number; match_id: number
victim: PlayerKillData; victim: PlayerKillData
attacker: PlayerKillData; attacker: PlayerKillData
distance: number; distance: number
cause_of_death: string; cause_of_death: string
}; }
export type RequestBody<T> = Request<any, any, T>
export const validateBody = export const validateBody =
<T>(checker: (input: T) => typia.IValidation<T>): RequestHandler => <T>(checker: (input: T) => typia.IValidation<T>): RequestHandler =>
(req, res, next) => { (req, res, next) => {
const result: typia.IValidation<T> = checker(req.body); const result: typia.IValidation<T> = checker(req.body)
if (!result.success) { if (!result.success) {
res.status(400).send({ errors: result.errors }); res.status(400).send({ errors: result.errors })
console.error(result.errors) console.error(result.errors)
} else { } else {
next(); next()
}
} }
};