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