All files / src/server default-request.ts

94.11% Statements 16/17
50% Branches 1/2
100% Functions 8/8
94.11% Lines 16/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 501x           1x 82x     82x 82x 82x 82x   82x       607x       480x       163x 163x           132x       371x       227x       4x      
import {Logger} from "../logger";
import {RedisToken} from "../resp/protocol/redis-token";
import {IRequest} from "./request";
import {IServerContext} from "./server-context";
import {Session} from "./session";
 
export class DefaultRequest implements IRequest {
  private logger: Logger = new Logger(module.id);
 
  constructor(
    private server: IServerContext,
    private session: Session,
    private command: string,
    private params: string[]
  ) {
      this.logger.debug(`constructor(server, ${session.getId()}, ${command}, ${params})`);
  }
 
  public getCommand(): string {
      return this.command.toString();
  }
 
  public getParams(): string[] {
      return this.params;
  }
 
  public getParam(index: number): string {
      Eif (index < this.params.length) {
          return this.params[index];
      }
      return "";
  }
 
  public getLength(): number {
      return this.params.length;
  }
 
  public getSession(): Session {
      return this.session;
  }
 
  public getServerContext(): IServerContext {
      return this.server;
  }
 
  public toString(): string {
      return `${this.command}[${this.params.length}]: ${this.params}`;
  }
}