dsql-admin/dsql-app/.local_dist/server/chunks/6715.js
2024-11-05 12:12:42 +01:00

67 lines
2.4 KiB
JavaScript

"use strict";
exports.id = 6715;
exports.ids = [6715];
exports.modules = {
/***/ 6715:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
/**
* Imports: Handle imports
*/ /**
* Grab Paths Function
* ==============================================================================
* @description Description
*
* @param {object} params - An object containing the function parameters.
* @param {boolean} [params.isPrivate] - Is this file private or not?
* @param {any} params.user - User object
* @param {string} [params.folder] - Folder, if available
* @param {boolean} [params.video] - Video, if available
* @param {boolean} [params.pathOnly] - Just generate the directories' paths
*
* @returns {{ fileRootPath: string, urlRootPath: string, relativePath: string } | null}
*/ module.exports = function grabPaths({ isPrivate , user , folder , video , pathOnly , }) {
/**
* Initialize variables
*/ const isProduction = "production".match(/production/);
const userId = user?.id || user?.user_id;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Handle function logic
*/ const STATIC_ROOT = process.env.DSQL_STATIC_SERVER_DIR;
if (!STATIC_ROOT) {
console.log("Static File ENV not Found!");
return null;
}
const relativePath = isPrivate ? `@/${video ? "videos" : "media"}/${folder ? folder + "/" : ""}` : video ? `/videos/user-videos/user-${userId}/${folder ? folder + "/" : ""}` : `/images/user-images/user-${userId}/${folder ? folder + "/" : ""}`;
const fileRootPath = isPrivate ? `./jsonData/dbSchemas/users/user-${userId}/media/${folder ? folder + "/" : ""}` : path.join(STATIC_ROOT, relativePath);
if (!fs.existsSync(fileRootPath) && !pathOnly) {
fs.mkdirSync(fileRootPath, {
recursive: true
});
}
const urlRootPath = isPrivate ? `@/media/${folder ? folder + "/" : ""}` : `${process.env.DSQL_STATIC_HOST}${relativePath}`;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Return statement
*/ return {
fileRootPath: fileRootPath,
urlRootPath: urlRootPath,
relativePath
};
};
/***/ })
};
;