mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
more refactor
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import {
|
||||
basePath,
|
||||
directoryOrFileExists,
|
||||
} from "../../../services/fileStorage/utils/fileSystemUtils";
|
||||
import { basePath, directoryOrFileExists } from "./fileSystemUtils";
|
||||
import { quizFileStorageService } from "../quizzes/quizFileStorageService";
|
||||
import { pageFileStorageService } from "../pages/pageFileStorageService";
|
||||
import { moduleFileStorageService } from "../modules/moduleFileStorageService";
|
||||
|
||||
22
src/features/local/utils/fileSystemUtils.ts
Normal file
22
src/features/local/utils/fileSystemUtils.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { promises as fs } from "fs";
|
||||
import { getGlobalSettings } from "../globalSettings/globalSettingsFileStorageService";
|
||||
|
||||
export const directoryOrFileExists = async (
|
||||
directoryPath: string
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
await fs.access(directoryPath);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export async function getCourseNames() {
|
||||
console.log("loading course ids");
|
||||
const globalSettings = await getGlobalSettings();
|
||||
return globalSettings.courses.map((course) => course.name);
|
||||
}
|
||||
|
||||
export const basePath = process.env.STORAGE_DIRECTORY ?? "./storage";
|
||||
console.log("base path", basePath);
|
||||
Reference in New Issue
Block a user