Skip to content

Commit

Permalink
fix: do not crash dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
PupoSDC committed Nov 15, 2023
1 parent ab75b01 commit 28dd6c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
4 changes: 0 additions & 4 deletions libs/content/interview-flashcards/src/interview-flashcards.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -18,9 +17,6 @@ export const preloadInterviewFlashcardsForStaticRender = async ({
}: {
readFile: (path: string, string: "utf-8") => Promise<string>;
}) => {
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<string, FlashcardContent[]>;
Expand Down
9 changes: 2 additions & 7 deletions libs/content/question-bank-737/src/question-bank-737.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getEnvVariableOrDefault } from "@chair-flight/base/env";
import { NotFoundError } from "@chair-flight/base/errors";
import {
API_PATH_QUESTIONS,
Expand Down Expand Up @@ -52,11 +51,8 @@ export const preloadQuestionBank737ForStaticRender = async ({
readFile,
}: {
readFile: (path: string, string: "utf-8") => Promise<string>;
}) => {
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"));
Expand All @@ -68,4 +64,3 @@ export const preloadQuestionBank737ForStaticRender = async ({
questions = file as QuestionTemplate[];
})(),
]);
};
9 changes: 2 additions & 7 deletions libs/content/question-bank-atpl/src/question-bank-atpl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getEnvVariableOrDefault } from "@chair-flight/base/env";
import { NotFoundError } from "@chair-flight/base/errors";
import {
API_PATH_LOS,
Expand Down Expand Up @@ -109,11 +108,8 @@ export const preloadQuestionBankAtplForStaticRender = async ({
readFile,
}: {
readFile: (path: string, string: "utf-8") => Promise<string>;
}) => {
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"));
Expand All @@ -130,4 +126,3 @@ export const preloadQuestionBankAtplForStaticRender = async ({
learningObjectives = file as LearningObjective[];
})(),
]);
};

0 comments on commit 28dd6c9

Please sign in to comment.