Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/server/src/NodesPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ export class NodesPool {
* Initialize nodes
*/
private async initializeNodes() {
const disabled_nodes = process.env.DISABLED_NODES ? process.env.DISABLED_NODES.split(',') : []
const packagePath = getNodeModulesPackagePath('flowise-components')
const nodesPath = path.join(packagePath, 'dist', 'nodes')
const nodeFiles = await this.getFiles(nodesPath)
return Promise.all(
const nodes = await this.loadNodesFromDir(nodesPath)
Object.assign(this.componentNodes, nodes)
}

/**
* Load and filter nodes from a directory.
*/
async loadNodesFromDir(dir: string): Promise<IComponentNodes> {
const disabled_nodes = process.env.DISABLED_NODES ? process.env.DISABLED_NODES.split(',') : []
const nodes: IComponentNodes = {}
const nodeFiles = await this.getFiles(dir)
await Promise.all(
nodeFiles.map(async (file) => {
if (file.endsWith('.js')) {
try {
Expand Down Expand Up @@ -69,7 +78,7 @@ export class NodesPool {
const isDisabled = disabled_nodes.includes(newNodeInstance.name)

if (conditionOne && conditionTwo && !isDisabled) {
this.componentNodes[newNodeInstance.name] = newNodeInstance
nodes[newNodeInstance.name] = newNodeInstance
}
}
} catch (err) {
Expand All @@ -78,6 +87,7 @@ export class NodesPool {
}
})
)
return nodes
}

/**
Expand Down