47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
|
// @ts-check
|
||
|
|
||
|
const serverError = require("./serverError");
|
||
|
const fs = require("fs");
|
||
|
const path = require("path");
|
||
|
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
|
||
|
/**
|
||
|
* ==============================================================================
|
||
|
* @param {Object} params
|
||
|
* @param {string | number} params.userId
|
||
|
* @returns {import("../../types").DSQL_DatabaseSchemaType[] | null}
|
||
|
*/
|
||
|
export default function grabUserSchemaData({ userId }) {
|
||
|
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 (/** @type {any} */ error) {
|
||
|
serverError({
|
||
|
component: "grabUserSchemaData",
|
||
|
message: error.message,
|
||
|
});
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|
||
|
/** ****************************************************************************** */
|