From 53162ba462d9f5d1d8d151445119f1704438a014 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 22 Oct 2020 17:32:05 +0200 Subject: [PATCH] :zap: Minor improvements on loading parameters on demand --- packages/cli/src/Server.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 7df867a034..df7dbdaf8f 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -715,11 +715,12 @@ class App { const allNodes = nodeTypes.getAll(); allNodes.forEach((nodeData) => { - // Make a copy of the object. If we don't do this, then when + // Make a copy of the object. If we don't do this, then when // The method below is called the properties are removed for good // This happens because nodes are returned as reference. - let nodeInfo: INodeTypeDescription = {...nodeData.description}; - if (!['true', '1'].includes(req.query.includeProperties as string)) { + const nodeInfo: INodeTypeDescription = {...nodeData.description}; + if (req.query.includeProperties !== 'true') { + // @ts-ignore delete nodeInfo.properties; } returnData.push(nodeInfo); @@ -731,10 +732,16 @@ class App { // Returns node information baesd on namese this.app.post(`/${this.restEndpoint}/node-types`, ResponseHelper.send(async (req: express.Request, res: express.Response): Promise => { - const nodeNames = _.get(req, 'body.nodeNames', []); + const nodeNames = _.get(req, 'body.nodeNames', []) as string[]; const nodeTypes = NodeTypes(); - const allNodes = nodeTypes.getAll(); - return allNodes.filter(node => nodeNames.includes(node.description.name)).map(node => node.description); + + return nodeNames.map(name => { + try { + return nodeTypes.getByName(name); + } catch (e) { + return undefined; + } + }).filter(nodeData => !!nodeData).map(nodeData => nodeData!.description); }));