mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
24 lines
522 B
TypeScript
24 lines
522 B
TypeScript
import { RpcParamtype } from '../enums/rpc-paramtype.enum';
|
|
|
|
export class RpcParamsFactory {
|
|
public exchangeKeyForValue(
|
|
type: number,
|
|
data: string | undefined,
|
|
args: unknown[],
|
|
) {
|
|
if (!args) {
|
|
return null;
|
|
}
|
|
switch (type as RpcParamtype) {
|
|
case RpcParamtype.PAYLOAD:
|
|
return data ? args[0]?.[data] : args[0];
|
|
case RpcParamtype.CONTEXT:
|
|
return args[1];
|
|
case RpcParamtype.GRPC_CALL:
|
|
return args[2];
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
}
|