mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
Merge pull request #1800 from mokeyish/patch-2
Allow default variable values when testing CustomFunction
This commit is contained in:
@@ -324,7 +324,10 @@ export class App {
|
|||||||
// execute custom function node
|
// execute custom function node
|
||||||
this.app.post('/api/v1/node-custom-function', async (req: Request, res: Response) => {
|
this.app.post('/api/v1/node-custom-function', async (req: Request, res: Response) => {
|
||||||
const body = req.body
|
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')) {
|
if (Object.prototype.hasOwnProperty.call(this.nodesPool.componentNodes, 'customFunction')) {
|
||||||
try {
|
try {
|
||||||
const nodeInstanceFilePath = this.nodesPool.componentNodes['customFunction'].filePath as string
|
const nodeInstanceFilePath = this.nodesPool.componentNodes['customFunction'].filePath as string
|
||||||
|
|||||||
Reference in New Issue
Block a user