From 8c0387c815281e2ebe1735311ac0e07ee4ef166b Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Thu, 26 Oct 2023 20:10:20 +0100 Subject: [PATCH] get workspace from module in getLayer --- mod/workspace/getLayer.js | 4 +++- mod/workspace/getTemplate.js | 8 +------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/mod/workspace/getLayer.js b/mod/workspace/getLayer.js index 7d7a59304..7617f4eaa 100644 --- a/mod/workspace/getLayer.js +++ b/mod/workspace/getLayer.js @@ -4,9 +4,11 @@ const merge = require('../utils/merge') const getTemplate = require('./getTemplate') +const workspaceCache = require('./cache') + module.exports = async (req) => { - const workspace = req.params.workspace + const workspace = await workspaceCache() if (!Object.hasOwn(workspace.locales, req.params.locale)) { return new Error('Unable to validate locale param.') //400 diff --git a/mod/workspace/getTemplate.js b/mod/workspace/getTemplate.js index 8a53cb719..45f003839 100644 --- a/mod/workspace/getTemplate.js +++ b/mod/workspace/getTemplate.js @@ -26,13 +26,7 @@ module.exports = async (template) => { return template } - if (typeof getFrom[template.src.split(':')[0]] !== 'function') { - - console.warn(`getFrom[${template.src.split(':')[0]}] is not a method.`); - return template - } - - const response = await getFrom[template.src.split(':')[0]]?.(template.src) + const response = await getFrom[template.src.split(':')[0]](template.src) if (response instanceof Error) {