mirror of
https://github.com/Pandipipas/scoreko-dev.git
synced 2026-06-06 03:32:06 +00:00
Refactor and simplify start.gg import flow code
This commit is contained in:
@@ -48,7 +48,6 @@ interface OAuthConfig {
|
||||
interface OAuthSession {
|
||||
sessionId: string;
|
||||
state: string;
|
||||
createdAt: number;
|
||||
expiresAt: number;
|
||||
status: 'pending' | 'completed' | 'error' | 'expired';
|
||||
token?: string;
|
||||
@@ -91,8 +90,9 @@ const requestStartGG = async <T>(query: string, variables: Record<string, unknow
|
||||
return payload.data;
|
||||
};
|
||||
|
||||
const countryByCode = new Set(getData().map((country: CountryRecord) => country.code.toUpperCase()));
|
||||
const countryByName = new Map(getData().map((country: CountryRecord) => [country.name.toLowerCase(), country.code.toUpperCase()]));
|
||||
const countries = getData();
|
||||
const countryByCode = new Set(countries.map((country: CountryRecord) => country.code.toUpperCase()));
|
||||
const countryByName = new Map(countries.map((country: CountryRecord) => [country.name.toLowerCase(), country.code.toUpperCase()]));
|
||||
|
||||
const resolveCountryCodeFromStartGG = (country: string | null | undefined): string => {
|
||||
const raw = (country || '').trim();
|
||||
@@ -346,12 +346,10 @@ nodecg.listenFor('startgg:createOAuthSession', async (_payload: unknown, ack) =>
|
||||
|
||||
const sessionId = randomUUID();
|
||||
const state = randomUUID();
|
||||
const now = Date.now();
|
||||
const session: OAuthSession = {
|
||||
sessionId,
|
||||
state,
|
||||
createdAt: now,
|
||||
expiresAt: now + STARTGG_OAUTH_SESSION_TTL_MS,
|
||||
expiresAt: Date.now() + STARTGG_OAUTH_SESSION_TTL_MS,
|
||||
status: 'pending',
|
||||
};
|
||||
oauthSessions.set(sessionId, session);
|
||||
|
||||
Reference in New Issue
Block a user