All files / lib/utils context.ts

71.43% Statements 5/7
50% Branches 2/4
100% Functions 1/1
71.43% Lines 5/7

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    5x 162x   140x   22x 22x              
import { ExecutionContext } from '@nestjs/common';
 
export function getContextObject(context: ExecutionContext): any {
  switch (context.getType() as string) {
    case 'http':
      return context.switchToHttp().getRequest();
    case 'graphql':
      const [, , ctx] = context.getArgs();
      return ctx;
    case 'rpc':
      return context.switchToRpc().getContext();
    default:
      console.warn(`context type: ${context.getType()} not supported`);
  }
}