Let the import throw error instead

This commit is contained in:
Fang-Pen Lin
2025-11-20 08:57:06 -08:00
parent f5936cad7e
commit fbaf8d37a3
@@ -8,14 +8,10 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
export const registerBddNockRouter = async (server: FastifyZodProvider) => { export const registerBddNockRouter = async (server: FastifyZodProvider) => {
const importNock = async () => { const importNock = () => {
// Notice: it seems like importing nock somehow increase memory usage a lots, let's import it lazily. // Notice: it seems like importing nock somehow increase memory usage a lots, let's import it lazily.
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
const nock = await import("nock"); return import("nock");
if (!nock) {
throw new InternalServerError({ message: "Failed to import nock" });
}
return nock;
}; };
const checkIfBddNockApiEnabled = () => { const checkIfBddNockApiEnabled = () => {