Mock third party calls

This commit is contained in:
Fang-Pen Lin
2025-11-13 09:21:53 -08:00
parent 8246483e8a
commit 1a18096ac8
5 changed files with 194 additions and 0 deletions
+7
View File
@@ -26,6 +26,7 @@ import { TSmtpService } from "@app/services/smtp/smtp-service";
import { TSuperAdminDALFactory } from "@app/services/super-admin/super-admin-dal";
import { globalRateLimiterCfg } from "./config/rateLimiter";
import { mockThirdPartyApiCalls } from "./mock-third-party-api-calls";
import { addErrorsToResponseSchemas } from "./plugins/add-errors-to-response-schemas";
import { apiMetrics } from "./plugins/api-metrics";
import { fastifyErrHandler } from "./plugins/error-handler";
@@ -66,6 +67,12 @@ export const main = async ({
}: TMain) => {
const appCfg = getConfig();
if (appCfg.shouldMockThirdPartyApiCalls) {
logger?.info("Mocking third party API calls for BDD");
// Note: to make BDD tests much easier, we mock some third party API calls here
mockThirdPartyApiCalls();
}
const server = fastify({
logger: appCfg.NODE_ENV === "test" ? false : logger,
genReqId: () => `req-${alphaNumericNanoId(14)}`,