Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | export const getEnvVariable = ( |
| 2 | name: string, |
| 3 | defaultValue: string | undefined = undefined |
| 4 | ): string | undefined => { |
| 5 | try { |
| 6 | return process.env[name] || defaultValue; |
| 7 | } catch (_e) { |
| 8 | return defaultValue; |
| 9 | } |
| 10 | }; |
| 11 | |
| 12 | /** |
| 13 | * Method to return all the envs based on a specific prefix |
| 14 | * @param prefix |
| 15 | * @example |
| 16 | * COMPOSIO_TOOLKIT_VERSION_GITHUB=20250902_00 |
| 17 | * COMPOSIO_TOOLKIT_VERSION_SLACK=20250902_00 |
| 18 | * COMPOSIO_TOOLKIT_VERSION_GMAIL=latest |
| 19 | * @returns {Record<string, unknown>} |
| 20 | * @returns |
| 21 | */ |
| 22 | export const getEnvsWithPrefix = (prefix: string): Record<string, unknown> => { |
| 23 | try { |
| 24 | if (process && process.env) { |
| 25 | return Object.fromEntries( |
| 26 | Object.entries(process.env).filter(([key]) => key.startsWith(prefix)) |
| 27 | ); |
| 28 | } else { |
| 29 | return {}; |
| 30 | } |
| 31 | } catch (error) { |
| 32 | return {}; |
| 33 | } |
| 34 | }; |