You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
use dockers for tests, use npm workspaces, add rejson & redisearch modules, fix some bugs
This commit is contained in:
64
packages/client/lib/commands/HELLO.ts
Normal file
64
packages/client/lib/commands/HELLO.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { AuthOptions } from './AUTH';
|
||||
|
||||
interface HelloOptions {
|
||||
protover: number;
|
||||
auth?: Required<AuthOptions>;
|
||||
clientName?: string;
|
||||
}
|
||||
|
||||
export function transformArguments(options?: HelloOptions): Array<string> {
|
||||
const args = ['HELLO'];
|
||||
|
||||
if (options) {
|
||||
args.push(options.protover.toString());
|
||||
|
||||
if (options.auth) {
|
||||
args.push('AUTH', options.auth.username, options.auth.password);
|
||||
}
|
||||
|
||||
if (options.clientName) {
|
||||
args.push('SETNAME', options.clientName);
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
type HelloRawReply = [
|
||||
_: never,
|
||||
server: string,
|
||||
_: never,
|
||||
version: string,
|
||||
_: never,
|
||||
proto: number,
|
||||
_: never,
|
||||
id: number,
|
||||
_: never,
|
||||
mode: string,
|
||||
_: never,
|
||||
role: string,
|
||||
_: never,
|
||||
modules: Array<string>
|
||||
];
|
||||
|
||||
interface HelloTransformedReply {
|
||||
server: string;
|
||||
version: string;
|
||||
proto: number;
|
||||
id: number;
|
||||
mode: string;
|
||||
role: string;
|
||||
modules: Array<string>;
|
||||
}
|
||||
|
||||
export function transformReply(reply: HelloRawReply): HelloTransformedReply {
|
||||
return {
|
||||
server: reply[1],
|
||||
version: reply[3],
|
||||
proto: reply[5],
|
||||
id: reply[7],
|
||||
mode: reply[9],
|
||||
role: reply[11],
|
||||
modules: reply[13]
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user