UNPKG

@ibm-adw/skill-toolkit

Version:

Developing your own skills with IBM Automation Digital Worker Skill Toolkit

46 lines (39 loc) 1.34 kB
/* Licensed Materials - Property of IBM 5737-I23 Copyright IBM Corp. 2019. All Rights Reserved. U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ 'use strict'; const path = require('path'); module.exports = async function (req, res) { const SKILL_DIR_1 = process.argv[2]; const SKILL_DIR = path.resolve(process.env.PWD, SKILL_DIR_1); try { const skill_to_be_tested = require(`${SKILL_DIR}/skill-config`); if (skill_to_be_tested.snippet) { try { const result = await skill_to_be_tested.snippet(global.skillConfiguration); res.set('Content-Type', 'text/plain'); res.status(200).send(result); } catch (error) { console.log(error); res.status(500).json({ name: error.name, message: error.message }); } } else { console.log('The function \'snippet\' is not implemented'); res.status(404).send('The function \'snippet\' is not implemented'); } } catch (error) { console.log(error); res.status(500).json({ name: error.name, message: error.message }); } };