-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5346 from novuhq/small_dx_touch_leveraging_env_va…
…r_in_node_sdk Small dx touch leveraging env var in node sdk
- Loading branch information
Showing
13 changed files
with
2,368 additions
and
221 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
export * from './entities/user'; | ||
export * from './entities/organization'; | ||
export * from './entities/notification-template'; | ||
export * from './config'; | ||
export * from './consts'; | ||
export * from './dto'; | ||
export * from './entities/change'; | ||
export * from './entities/environment'; | ||
export * from './entities/execution-details'; | ||
export * from './entities/messages'; | ||
export * from './entities/feed/feed.interface'; | ||
export * from './entities/notification'; | ||
export * from './entities/message-template'; | ||
export * from './entities/integration'; | ||
export * from './entities/job'; | ||
export * from './entities/layout'; | ||
export * from './entities/log'; | ||
export * from './entities/change'; | ||
export * from './entities/message-template'; | ||
export * from './entities/messages'; | ||
export * from './entities/notification-group'; | ||
export * from './entities/notification-template'; | ||
export * from './entities/notification'; | ||
export * from './entities/organization'; | ||
export * from './entities/step'; | ||
export * from './entities/job'; | ||
export * from './entities/subscriber-preference'; | ||
export * from './entities/subscriber'; | ||
export * from './entities/layout'; | ||
export * from './entities/notification-group'; | ||
export * from './entities/integration'; | ||
export * from './entities/tenant'; | ||
export * from './entities/user'; | ||
export * from './entities/workflow-override'; | ||
export * from './services'; | ||
export * from './types'; | ||
export * from './dto'; | ||
export * from './consts'; | ||
export * from './ui'; | ||
export * from './services'; | ||
export * from './config'; | ||
export * from './utils'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
type CloudflareEnv = { env: Record<string, string> }; | ||
|
||
// https://remix.run/blog/remix-vite-stable#cloudflare-pages-support | ||
const hasCloudflareProxyContext = (context: any): context is { cloudflare: CloudflareEnv } => { | ||
return !!context?.cloudflare?.env; | ||
}; | ||
|
||
const hasCloudflareContext = (context: any): context is CloudflareEnv => { | ||
return !!context?.env; | ||
}; | ||
|
||
/** | ||
* | ||
* Utility function to get env variables across Node and Edge runtimes. | ||
* | ||
* @param name Pass the name of the environment variable. The param is case-sensitive. | ||
* @returns string Returns the value of the environment variable if exists. | ||
*/ | ||
export const getEnvVariable = (name: string, context?: any): string => { | ||
// Node envs | ||
if (typeof process !== 'undefined' && process.env && typeof process.env[name] === 'string') { | ||
return process.env[name] as string; | ||
} | ||
|
||
/* | ||
* Remix + Cloudflare pages | ||
* if (typeof (context?.cloudflare as CloudflareEnv)?.env !== 'undefined') { | ||
*/ | ||
if (hasCloudflareProxyContext(context)) { | ||
return context.cloudflare.env[name] || ''; | ||
} | ||
|
||
// Cloudflare | ||
if (hasCloudflareContext(context)) { | ||
return context.env[name] || ''; | ||
} | ||
|
||
// Check whether the value exists in the context object directly | ||
if (context && typeof context[name] === 'string') { | ||
return context[name] as string; | ||
} | ||
|
||
// Cloudflare workers | ||
try { | ||
return globalThis[name as keyof typeof globalThis]; | ||
} catch (_) { | ||
// This will raise an error in Cloudflare Pages | ||
} | ||
|
||
return ''; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './env'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
moduleNameMapper: { | ||
uuid: require.resolve('uuid'), | ||
}, | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.