|
|
@ -14,6 +14,7 @@ const basePath = path.join(path.resolve(), '/../../')
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* asset - checks manifest.json for given path and return
|
|
|
|
* asset - checks manifest.json for given path and return
|
|
|
|
* file path with id for cache busting
|
|
|
|
* file path with id for cache busting
|
|
|
@ -82,7 +83,7 @@ function isHome(entity) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* injectStore
|
|
|
|
* injectStore -
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param {String} name
|
|
|
|
* @param {String} name
|
|
|
@ -91,19 +92,21 @@ function isHome(entity) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
async function injectStore(name) {
|
|
|
|
async function injectStore(name) {
|
|
|
|
|
|
|
|
|
|
|
|
const path = './../stores/' + name + '.js'
|
|
|
|
const importPath = './../stores/' + name + '.js'
|
|
|
|
|
|
|
|
const filePath = basePath + 'packages/server/stores/' + name + '.js'
|
|
|
|
|
|
|
|
|
|
|
|
// if file
|
|
|
|
// if class not exists, throw exception
|
|
|
|
//if (!fs.existsSync(path)) {
|
|
|
|
if (!fs.existsSync(filePath)) {
|
|
|
|
//throw new Error(name + ' not exists!')
|
|
|
|
throw new Error(name + ' not exists!')
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const StoreClass = await import(path)
|
|
|
|
const StoreClass = await import(importPath)
|
|
|
|
const store = new StoreClass.default()
|
|
|
|
const store = new StoreClass.default()
|
|
|
|
|
|
|
|
|
|
|
|
return store
|
|
|
|
return store
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* getting url for assets of directus api
|
|
|
|
* getting url for assets of directus api
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -112,15 +115,15 @@ async function injectStore(name) {
|
|
|
|
* @return string
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function fileUrl(id, options = NULL)
|
|
|
|
function mediaUrl(id, options = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$query = NULL;
|
|
|
|
let query = '';
|
|
|
|
|
|
|
|
|
|
|
|
if (options) {
|
|
|
|
if (options) {
|
|
|
|
$query = '?'.http_build_query($options);
|
|
|
|
query = '?' + new URLSearchParams(options).toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return process.ENV.DIRECTUS_API_URL + '/assets/' + id + $query;
|
|
|
|
return process.env.DIRECTUS_API_URL + '/assets/' + id + query;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export { asset, templateClass, isHome, injectStore }
|
|
|
|
export { asset, templateClass, isHome, injectStore, mediaUrl }
|