datasquirel/package-shared/functions/backend/grabUserSchemaData.ts
2025-01-10 20:10:28 +01:00

32 lines
797 B
TypeScript
Executable File

import serverError from "./serverError";
import fs from "fs";
import path from "path";
/**
* # Grab User Schema Data
*/
export default function grabUserSchemaData({
userId,
}: {
userId: string | number;
}): import("../../types").DSQL_DatabaseSchemaType[] | null {
try {
const userSchemaFilePath = path.resolve(
process.cwd(),
`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${userId}/main.json`
);
const userSchemaData = JSON.parse(
fs.readFileSync(userSchemaFilePath, "utf-8")
);
return userSchemaData;
} catch (error: any) {
serverError({
component: "grabUserSchemaData",
message: error.message,
});
return null;
}
}