Where to put common code used by several function nodes?

Hello

I think that the title speaks for itself :slight_smile: a best practice ?

ps up please for error-WF

There is currently sadly nothing which allows that. The only way I can think of is to create an own separate npm module which then could be used in the Function-Node.

Pity … thanks jan.

Checking on this a few years later :slight_smile: … I have the same issue where I don’t want to replicate some standard code (basically a few lines to authorize using a custom database)

This auth code will need to run before every workflow in my “package for an app”

Is there anything that enables this now @jan @harshil1712

Thank you!

1 Like

Hey @Santosh_Srinivas,

Did you try creating a sub-workflow using the Execute Workflow node? If that doesn’t solve your issue, can you please open a Feature Request sharing all the details? :slight_smile:

This looks almost there @harshil1712 … will try out!

Just in case you have handy examples, please guide me:

My reusable auth workflows will take: public_key and private key => validate with a database query => return {“authorized”: true/false} … that will carry on in my main workflow

Please advise anything that can point me in the right direction. will try out.

Thanks @harshil1712 the execute workflow node did it! Many thanks!

1 Like

That’s fantastic! I was working on an example, but I am glad you find the solution yourself :sparkles: