Files
Edu/services/teacher-bff/src/clients/iam/iam.module.ts
SpecialX 99155a5ea1 feat(teacher-bff): 完整实现 teacher-bff GraphQL 聚合层
包含 clients/graphql/middleware、health probes、shared-ts contracts 等
2026-07-10 19:10:07 +08:00

32 lines
923 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// iam 模块B8 裁决:按 DEV_MODE 选择 mock 或 gRPC 实现)
import { Module } from "@nestjs/common";
import { env } from "../../config/env.js";
import { logger } from "../../shared/observability/logger.js";
import { IAM_CLIENT } from "./iam-client.interface.js";
import { IamGrpcClient } from "./iam-grpc.client.js";
import { IamMockClient } from "./iam-mock.client.js";
@Module({
providers: [
{
provide: IAM_CLIENT,
useFactory: () => {
if (env.TEACHER_BFF_DEV_MODE) {
logger.warn(
{ devMode: true },
"IamClient using mock (TEACHER_BFF_DEV_MODE=true)",
);
return new IamMockClient();
}
logger.info(
{ devMode: false, target: env.IAM_GRPC_TARGET },
"IamClient using gRPC",
);
return new IamGrpcClient();
},
},
],
exports: [IAM_CLIENT],
})
export class IamModule {}