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
@@ -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) ?? '';
|
||||
}
|
||||
Reference in new issue
Block a user