1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-03 04:01:40 +03:00
Files
node-redis/packages/client/lib/commands/ACL_LOG.ts
2021-12-20 14:47:51 -05:00

51 lines
1.2 KiB
TypeScript

import { RedisCommandArgument, RedisCommandArguments } from '.';
export function transformArguments(count?: number): RedisCommandArguments {
const args = ['ACL', 'LOG'];
if (count) {
args.push(count.toString());
}
return args;
}
type AclLogRawReply = [
_: RedisCommandArgument,
count: number,
_: RedisCommandArgument,
reason: RedisCommandArgument,
_: RedisCommandArgument,
context: RedisCommandArgument,
_: RedisCommandArgument,
object: RedisCommandArgument,
_: RedisCommandArgument,
username: RedisCommandArgument,
_: RedisCommandArgument,
ageSeconds: RedisCommandArgument,
_: RedisCommandArgument,
clientInfo: RedisCommandArgument
];
interface AclLog {
count: number;
reason: RedisCommandArgument;
context: RedisCommandArgument;
object: RedisCommandArgument;
username: RedisCommandArgument;
ageSeconds: number;
clientInfo: RedisCommandArgument;
}
export function transformReply(reply: Array<AclLogRawReply>): Array<AclLog> {
return reply.map(log => ({
count: log[1],
reason: log[3],
context: log[5],
object: log[7],
username: log[9],
ageSeconds: Number(log[11]),
clientInfo: log[13]
}));
}