fix(api): resolve lint errors
This commit is contained in:
1 parent
96fede9fe5
commit
fd1fa2366c
42 files changed
+307
-199
No files matched your search
@@ -151,7 +151,7 @@ export class AuctionRedisStateReaderService {
|
||||
revision: number;
|
||||
},
|
||||
shouldForceAuctionStateResync: options.shouldForceAuctionStateResync,
|
||||
structureState: JSON.parse(structureStateJson) as Record<string, unknown>,
|
||||
structureState: parseJsonRecord(structureStateJson),
|
||||
});
|
||||
view.matchId = matchId;
|
||||
if (options.includeInternalLiveStateFields) {
|
||||
@@ -170,12 +170,9 @@ export class AuctionRedisStateReaderService {
|
||||
if (typeof structureStateJson !== 'string' || !structureStateJson) {
|
||||
return undefined;
|
||||
}
|
||||
const structureState = JSON.parse(structureStateJson) as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
const auctionTeams = Array.isArray(structureState.auctionTeams)
|
||||
? structureState.auctionTeams
|
||||
const structureState = parseJsonRecord(structureStateJson);
|
||||
const auctionTeams: unknown[] = Array.isArray(structureState.auctionTeams)
|
||||
? (structureState.auctionTeams as unknown[])
|
||||
: [];
|
||||
const bidderTeam = auctionTeams.find((entry) => {
|
||||
if (!entry || typeof entry !== 'object') return false;
|
||||
@@ -192,6 +189,13 @@ function stringValue(value: unknown): string | undefined {
|
||||
return typeof value === 'string' && value ? value : undefined;
|
||||
}
|
||||
|
||||
function parseJsonRecord(json: string): Record<string, unknown> {
|
||||
const value: unknown = JSON.parse(json);
|
||||
return typeof value === 'object' && value !== null
|
||||
? (value as Record<string, unknown>)
|
||||
: {};
|
||||
}
|
||||
|
||||
function parseHashReply(
|
||||
reply: unknown,
|
||||
options: { includeInternalLiveStateFields?: boolean } = {},
|
||||
|
||||
@@ -74,9 +74,11 @@ async function readFirstSecret(
|
||||
|
||||
const logger = new Logger('AuctionRedisClient');
|
||||
const client = createClient(auctionRedisOptions);
|
||||
client.on('error', (error) => {
|
||||
client.on('error', (error: unknown) => {
|
||||
logger.error(
|
||||
`Auction Redis client error: ${error?.message ?? error}`,
|
||||
`Auction Redis client error: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -85,9 +85,15 @@ export class AuctionRedisService implements OnModuleDestroy {
|
||||
if (!isNoscriptError(error)) throw error;
|
||||
}
|
||||
|
||||
const loadedSha = String(
|
||||
await this.client.sendCommand(['SCRIPT', 'LOAD', params.script]),
|
||||
);
|
||||
const loadedShaReply = await this.client.sendCommand([
|
||||
'SCRIPT',
|
||||
'LOAD',
|
||||
params.script,
|
||||
]);
|
||||
if (typeof loadedShaReply !== 'string') {
|
||||
throw new Error('Redis SCRIPT LOAD returned a non-string SHA.');
|
||||
}
|
||||
const loadedSha = loadedShaReply;
|
||||
return (await this.client.sendCommand(
|
||||
buildEvalShaCommand(loadedSha, params.keys, params.values),
|
||||
)) as T;
|
||||
@@ -111,7 +117,7 @@ export class AuctionRedisService implements OnModuleDestroy {
|
||||
token: string,
|
||||
ttlMS: number,
|
||||
): Promise<boolean> {
|
||||
const result = await this.client.sendCommand([
|
||||
const result = await this.client.sendCommand<string | null>([
|
||||
'SET',
|
||||
key,
|
||||
token,
|
||||
@@ -119,7 +125,7 @@ export class AuctionRedisService implements OnModuleDestroy {
|
||||
String(ttlMS),
|
||||
'NX',
|
||||
]);
|
||||
return String(result) === 'OK';
|
||||
return result === 'OK';
|
||||
}
|
||||
|
||||
public async releaseTokenLock(key: string, token: string): Promise<boolean> {
|
||||
|
||||
@@ -78,9 +78,7 @@ export function assembleAuctionViewFromRedisState(
|
||||
return {
|
||||
...params.structureState,
|
||||
...params.liveState,
|
||||
auctionBidHistory: params.auctionBidHistoryEntries.map((entry) =>
|
||||
JSON.parse(entry),
|
||||
),
|
||||
auctionBidHistory: params.auctionBidHistoryEntries.map(parseJsonValue),
|
||||
canPlaceBidInCurrentBidRound: !isExpiring,
|
||||
currentServerTimestampMS: params.currentServerTimestampMS,
|
||||
isAuctionStateTransitionInProgress: isExpiring,
|
||||
@@ -90,6 +88,11 @@ export function assembleAuctionViewFromRedisState(
|
||||
};
|
||||
}
|
||||
|
||||
function parseJsonValue(json: string): unknown {
|
||||
const value: unknown = JSON.parse(json);
|
||||
return value;
|
||||
}
|
||||
|
||||
export function buildHydrateAuctionStateScriptInvocation(
|
||||
keys: AuctionRedisKeys,
|
||||
input: HydrateAuctionStateScriptInput,
|
||||
|
||||
Reference in new issue
Block a user