From 28dd6c9117090e39a5e0719a440ee607b373fcee Mon Sep 17 00:00:00 2001 From: Pedro Pupo Sa da Costa Date: Wed, 15 Nov 2023 15:01:40 +0000 Subject: [PATCH] fix: do not crash dev mode --- .../interview-flashcards/src/interview-flashcards.ts | 4 ---- libs/content/question-bank-737/src/question-bank-737.ts | 9 ++------- .../content/question-bank-atpl/src/question-bank-atpl.ts | 9 ++------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/libs/content/interview-flashcards/src/interview-flashcards.ts b/libs/content/interview-flashcards/src/interview-flashcards.ts index 6790a896a..c53461106 100644 --- a/libs/content/interview-flashcards/src/interview-flashcards.ts +++ b/libs/content/interview-flashcards/src/interview-flashcards.ts @@ -1,4 +1,3 @@ -import { getEnvVariableOrDefault } from "@chair-flight/base/env"; import { API_PATH_FLASHCARDS, READ_PATH_FLASHCARDS } from "./constants"; import type { FlashcardContent } from "@chair-flight/base/types"; @@ -18,9 +17,6 @@ export const preloadInterviewFlashcardsForStaticRender = async ({ }: { readFile: (path: string, string: "utf-8") => Promise; }) => { - const stage = getEnvVariableOrDefault("NEXT_PHASE", "N/A"); - const doNotUseMessage = "Do not use this method outside NEXT.JS build time."; - if (stage !== "phase-production-build") throw new Error(doNotUseMessage); const path = `${process.cwd()}${READ_PATH_FLASHCARDS}`; const file = JSON.parse(await readFile(path, "utf-8")); flashcards = file as Record; diff --git a/libs/content/question-bank-737/src/question-bank-737.ts b/libs/content/question-bank-737/src/question-bank-737.ts index f94e9cae4..b5ce1db60 100644 --- a/libs/content/question-bank-737/src/question-bank-737.ts +++ b/libs/content/question-bank-737/src/question-bank-737.ts @@ -1,4 +1,3 @@ -import { getEnvVariableOrDefault } from "@chair-flight/base/env"; import { NotFoundError } from "@chair-flight/base/errors"; import { API_PATH_QUESTIONS, @@ -52,11 +51,8 @@ export const preloadQuestionBank737ForStaticRender = async ({ readFile, }: { readFile: (path: string, string: "utf-8") => Promise; -}) => { - const stage = getEnvVariableOrDefault("NEXT_PHASE", "N/A"); - const doNotUseMessage = "Do not use this method outside NEXT.JS build time."; - if (stage !== "phase-production-build") throw new Error(doNotUseMessage); - await Promise.all([ +}) => + Promise.all([ (async () => { const path = `${process.cwd()}${READ_PATH_SUBJECT}`; const file = JSON.parse(await readFile(path, "utf-8")); @@ -68,4 +64,3 @@ export const preloadQuestionBank737ForStaticRender = async ({ questions = file as QuestionTemplate[]; })(), ]); -}; diff --git a/libs/content/question-bank-atpl/src/question-bank-atpl.ts b/libs/content/question-bank-atpl/src/question-bank-atpl.ts index c2604b4ca..718fce4b6 100644 --- a/libs/content/question-bank-atpl/src/question-bank-atpl.ts +++ b/libs/content/question-bank-atpl/src/question-bank-atpl.ts @@ -1,4 +1,3 @@ -import { getEnvVariableOrDefault } from "@chair-flight/base/env"; import { NotFoundError } from "@chair-flight/base/errors"; import { API_PATH_LOS, @@ -109,11 +108,8 @@ export const preloadQuestionBankAtplForStaticRender = async ({ readFile, }: { readFile: (path: string, string: "utf-8") => Promise; -}) => { - const stage = getEnvVariableOrDefault("NEXT_PHASE", "N/A"); - const doNotUseMessage = "Do not use this method outside NEXT.JS build time."; - if (stage !== "phase-production-build") throw new Error(doNotUseMessage); - await Promise.all([ +}) => + Promise.all([ (async () => { const path = `${process.cwd()}${READ_PATH_SUBJECTS}`; const file = JSON.parse(await readFile(path, "utf-8")); @@ -130,4 +126,3 @@ export const preloadQuestionBankAtplForStaticRender = async ({ learningObjectives = file as LearningObjective[]; })(), ]); -};