import fs from 'fs' import path from 'path' /** * resolve action class * * @author Björn Hase * @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3 * @link https://git.node001.net/HerrHase/signpost.git * */ function resolveActionClass(className) { let classPath = path.join(process.env.APP_BASE_DIR, 'resources/actions/' + className + '.js') let result = undefined if (fs.existsSync(classPath)) { result = classPath } if (!result) { throw new Error('Action Class ' + className + ' / ' + classPath + ' not found!') } return result } /** * resolve schema * * @author Björn Hase * @link https://git.node001.net/HerrHase/signpost.git * */ function resolveSchema(schemaName) { let schemaPath = path.join(process.env.APP_BASE_DIR, 'resources/schemas/' + schemaName + '.json') let result = undefined if (fs.existsSync(schemaPath)) { result = schemaPath } if (!result) { throw new Error('Schema ' + schemaName + ' / ' + schemaPath + ' not found!') } return result } export { resolveActionClass, resolveSchema }