[V8] remove direct process.env access, replacing with getEnv helper#1312
Merged
[V8] remove direct process.env access, replacing with getEnv helper#1312
Conversation
Contributor
There was a problem hiding this comment.
Greptile Summary
This PR improves the cross-runtime compatibility of the WorkOS Node.js SDK by replacing direct process.env access with a new getEnv utility function. This change is particularly important as it:
- Enables the SDK to work in environments where
process.envisn't available (like Deno, Bun, Cloudflare Workers, etc.) - Centralizes environment variable access through a single utility function
- Makes the code more maintainable by abstracting environment handling
The changes specifically affect how WORKOS_API_KEY and WORKOS_CLIENT_ID are accessed in the WorkOS class.
Confidence score: 4/5
- This PR is safe to merge as it maintains existing functionality while improving runtime compatibility
- High confidence due to the straightforward nature of the changes and their clear benefits for cross-runtime support
- Files needing attention:
- src/common/utils/env.ts - Verify the implementation of getEnv utility
- src/workos.ts - Ensure all process.env accesses are properly replaced
1 file reviewed, 1 comment
Edit PR Review Bot Settings | Greptile
nholden
approved these changes
Jul 22, 2025
ericroberts
approved these changes
Jul 22, 2025
nicknisi
added a commit
that referenced
this pull request
Aug 5, 2025
nicknisi
added a commit
that referenced
this pull request
Aug 7, 2025
nicknisi
added a commit
that referenced
this pull request
Aug 19, 2025
nicknisi
added a commit
that referenced
this pull request
Aug 25, 2025
nicknisi
added a commit
that referenced
this pull request
Aug 28, 2025
nicknisi
added a commit
that referenced
this pull request
Sep 23, 2025
nicknisi
added a commit
that referenced
this pull request
Oct 2, 2025
nicknisi
added a commit
that referenced
this pull request
Oct 13, 2025
nicknisi
added a commit
that referenced
this pull request
Oct 28, 2025
nicknisi
added a commit
that referenced
this pull request
Nov 6, 2025
nicknisi
added a commit
that referenced
this pull request
Nov 24, 2025
nicknisi
added a commit
that referenced
this pull request
Dec 2, 2025
nicknisi
added a commit
that referenced
this pull request
Dec 4, 2025
nicknisi
added a commit
that referenced
this pull request
Dec 4, 2025
nicknisi
added a commit
that referenced
this pull request
Dec 16, 2025
nicknisi
added a commit
that referenced
this pull request
Dec 22, 2025
nicknisi
added a commit
that referenced
this pull request
Jan 8, 2026
nicknisi
added a commit
that referenced
this pull request
Jan 9, 2026
nicknisi
added a commit
that referenced
this pull request
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request refactors how environment variables are accessed in the
WorkOSclass to improve code clarity and maintainability. The changes replace direct access toprocess.envwith a utility functiongetEnv.Refactoring environment variable access:
src/workos.ts: Introduced thegetEnvutility function from./common/utils/envto centralize and simplify access to environment variables.src/workos.ts: Replaced direct usage ofprocess.env.WORKOS_API_KEYwithgetEnv('WORKOS_API_KEY')for retrieving the API key. This ensures consistent handling of environment variables across environments.src/workos.ts: Replaced direct usage ofprocess.env.WORKOS_CLIENT_IDwithgetEnv('WORKOS_CLIENT_ID')for retrieving the client ID. This further standardizes the approach to accessing environment variables.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.