All files / lib/utils context.ts

42.86% Statements 3/7
25% Branches 1/4
100% Functions 1/1
42.86% Lines 3/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    1x 24x   24x                    
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`);
  }
}