@softkit/i18n
Version:
This library is a simple wrapper based on [nestjs-i18n](https://nestjs-i18n.com/)
31 lines • 945 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContextObject = void 0;
const common_1 = require("@nestjs/common");
const logger = new common_1.Logger('I18nService');
function getContextObject(context) {
if (!context) {
logger.warn('The context is undefined');
return undefined;
}
const contextType = context?.getType() ?? 'undefined';
switch (contextType) {
case 'http': {
return context.switchToHttp().getRequest();
}
case 'graphql': {
return context.getArgs()[2];
}
case 'rpc': {
return context.switchToRpc().getContext();
}
case 'rmq': {
return context.getArgs()[1];
}
default: {
logger.warn(`context type: ${contextType} not supported`);
}
}
}
exports.getContextObject = getContextObject;
//# sourceMappingURL=context.js.map