feat: session persistance

This commit is contained in:
TresAbhi committed 2023-09-19 15:52:39 +00:00
1 parent 57f6e928b7
commit 018783bb47
12 files changed
+121 -29

No files matched your search

+5 -5
View File
@@ -1,18 +1,18 @@
import { REGION_NAMES, Region } from '../../constants/regions';
import { TanksStats } from '../../types/tanksStats';
import { TankStats } from '../../types/tanksStats';
import { secrets } from '../node/secrets';
import throwError from '../node/throwError';
import getWargamingResponse from './getWargamingResponse';
export default async function getTankStats(server: Region, id: number) {
const tankStats = await getWargamingResponse<TanksStats>(
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
export default async function getTankStats(region: Region, id: number) {
const tankStats = await getWargamingResponse<TankStats>(
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
);
if (tankStats[id] === null) {
throw throwError(
'No tank stats available',
`Wargaming says there is no tank stats for this account. This account may not have any battles/tanks or exist in the ${REGION_NAMES[server]} server.`,
`Wargaming says there is no tank stats for this account. This account may not have any battles/tanks or exist in the ${REGION_NAMES[region]} server.`,
);
}
+1 -1
View File
@@ -17,7 +17,7 @@ export const secrets = SECRET_KEYS.reduce<Partial<Record<SECRET, string>>>(
...accumulator,
get [key](): string {
if (!(key in process.env)) throw new Error(`Key ${key} not provided`);
if (!(key in process.env)) throw new Error(`Secret ${key} not provided`);
return process.env[key]!;
},
}),