Allow default variable values ​​when testing CustomFunction

```js
const question = $question ?? 'my default question'

```
This commit is contained in:
YISH
2024-02-23 15:52:26 +08:00
committed by GitHub
parent 39f6991b0f
commit d8af5effe9
+4 -1
View File
@@ -307,7 +307,10 @@ export class App {
// execute custom function node
this.app.post('/api/v1/node-custom-function', async (req: Request, res: Response) => {
const body = req.body
const nodeData = { inputs: body }
const functionInputVariables = Object.fromEntries(
[...(body?.javascriptFunction ?? '').matchAll(/\$([a-zA-Z0-9_]+)/g)].map((g) => [g[1], undefined])
)
const nodeData = { inputs: { functionInputVariables, ...body } }
if (Object.prototype.hasOwnProperty.call(this.nodesPool.componentNodes, 'customFunction')) {
try {
const nodeInstanceFilePath = this.nodesPool.componentNodes['customFunction'].filePath as string