fix(api): resolve lint errors

This commit is contained in:
dahyeon committed 2026-07-24 21:52:35 -07:00
1 parent 96fede9fe5
commit fd1fa2366c
42 files changed
+307 -199

No files matched your search

@@ -56,16 +56,11 @@ export class DistributedLockService {
const lockOwnershipToken = options.lockOwnershipToken ?? randomUUID();
const result = await this.redisService
.raw()
.sendCommand([
'SET',
options.lockKey,
lockOwnershipToken,
'NX',
'PX',
String(options.lockExpirationDurationMilliseconds),
]);
.sendCommand<
string | null
>(['SET', options.lockKey, lockOwnershipToken, 'NX', 'PX', String(options.lockExpirationDurationMilliseconds)]);
if (String(result) !== 'OK') return null;
if (result !== 'OK') return null;
return {
lockKey: options.lockKey,
lockOwnershipToken,
@@ -124,7 +119,7 @@ export class DistributedLockService {
await this.releaseLockIfOwned(lockOwnership).catch((error: unknown) => {
this.logger.warn(
`Failed to release distributed lock ${lockOwnership.lockKey}: ${
error instanceof Error ? error.message : error
error instanceof Error ? error.message : String(error)
}`,
);
});
@@ -143,8 +138,7 @@ export class DistributedLockService {
const lockOwnership = await this.acquireLockWithRetry(options);
if (!lockOwnership) return null;
let lockRenewalTimer: NodeJS.Timeout | undefined;
lockRenewalTimer = setInterval(() => {
const lockRenewalTimer = setInterval(() => {
void this.extendLockIfOwned(lockOwnership).then((wasExtended) => {
if (wasExtended) return;
this.logger.warn(
@@ -157,11 +151,11 @@ export class DistributedLockService {
try {
return await operation(lockOwnership);
} finally {
if (lockRenewalTimer) clearInterval(lockRenewalTimer);
clearInterval(lockRenewalTimer);
await this.releaseLockIfOwned(lockOwnership).catch((error: unknown) => {
this.logger.warn(
`Failed to release distributed lock ${lockOwnership.lockKey}: ${
error instanceof Error ? error.message : error
error instanceof Error ? error.message : String(error)
}`,
);
});
@@ -54,8 +54,12 @@ async function readFirstSecret(
}),
);
client.on('error', (error) => {
logger.error(`Redis client error: ${error?.message ?? error}`);
client.on('error', (error: unknown) => {
logger.error(
`Redis client error: ${
error instanceof Error ? error.message : String(error)
}`,
);
});
await client.connect();
@@ -35,11 +35,14 @@ interface RawStreamReadResult {
function normalizeStreamFields(fields: unknown): Record<string, string> {
if (Array.isArray(fields)) {
const values = fields as unknown[];
const normalized: Record<string, string> = {};
for (let index = 0; index < fields.length; index += 2) {
const key = fields[index];
for (let index = 0; index < values.length; index += 2) {
const key = values[index];
if (key === undefined) continue;
normalized[String(key)] = String(fields[index + 1] ?? '');
normalized[redisValueToString(key)] = redisValueToString(
values[index + 1],
);
}
return normalized;
}
@@ -260,10 +263,10 @@ export class RedisService implements OnModuleDestroy {
rawMessage: unknown,
): StreamEntry | null {
if (Array.isArray(rawMessage)) {
const [id, fields] = rawMessage;
const [id, fields] = rawMessage as unknown[];
if (id === undefined) return null;
return {
id: String(id),
id: redisValueToString(id),
message: normalizeStreamFields(fields),
};
}
@@ -291,3 +294,17 @@ export class RedisService implements OnModuleDestroy {
return null;
}
}
function redisValueToString(value: unknown): string {
if (typeof value === 'string') return value;
if (
typeof value === 'number' ||
typeof value === 'boolean' ||
typeof value === 'bigint'
) {
return String(value);
}
if (Buffer.isBuffer(value)) return value.toString('utf8');
if (value === undefined || value === null) return '';
return JSON.stringify(value) ?? '';
}