Skip to content

Commit 17c0df0

Browse files
committed
feat: provide safe defaults for env-based config; no .env required in VSIX
1 parent d5072e1 commit 17c0df0

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/utils/appConfig.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,29 @@ const rootPath = (filename: string) => path.resolve(__dirname, `../${filename}`)
55

66
require('dotenv').config({ path: rootPath('.env') })
77

8+
// Helper to read from env with a safe default so production doesn't require a .env file
9+
const fromEnv = (key: string, fallback: string): string => {
10+
const val = process.env[key]
11+
return typeof val === 'string' && val.length > 0 ? val : fallback
12+
}
13+
814
export const AppConfig = {
915
app: {
10-
sessionSecret: process.env.SESSIONS_SECRET_KEY as string,
11-
clientIdentifier: process.env.CLIENT_IDENTIFIER as string,
16+
// Key name for VS Code SecretStorage. Not a credential; safe to default.
17+
sessionSecret: fromEnv('SESSIONS_SECRET_KEY', 'pullflow.session'),
18+
// Public identifier for the client used during auth redirects.
19+
clientIdentifier: fromEnv('CLIENT_IDENTIFIER', 'com.pullflow.vscode'),
1220
},
1321
pullflow: {
14-
baseUrl: process.env['PULLFLOW_APP_URL'] as string,
15-
graphqlUrl: `${process.env['PULLFLOW_APP_URL']}/api/graphql`,
16-
telemetryUrl: process.env['PULLFLOW_TELEMETRY_URL'] as string,
22+
// Public service endpoints; default to production URLs.
23+
baseUrl: fromEnv('PULLFLOW_APP_URL', 'https://app.pullflow.com'),
24+
graphqlUrl: `${fromEnv(
25+
'PULLFLOW_APP_URL',
26+
'https://app.pullflow.com'
27+
)}/api/graphql`,
28+
telemetryUrl: fromEnv(
29+
'PULLFLOW_TELEMETRY_URL',
30+
'https://collector.pullflow.cloud'
31+
),
1732
},
1833
}

0 commit comments

Comments
 (0)