@@ -518,61 +518,30 @@ export function loadConfig() {
518518 config . telegram . allowed_users . push ( ownerId ) ;
519519 }
520520 }
521- if ( process . env . GITHUB_TOKEN ) {
522- if ( ! config . github ) config . github = { } ;
523- config . github . token = process . env . GITHUB_TOKEN ;
524- }
525- // ElevenLabs voice credentials
526- if ( process . env . ELEVENLABS_API_KEY ) {
527- if ( ! config . elevenlabs ) config . elevenlabs = { } ;
528- config . elevenlabs . api_key = process . env . ELEVENLABS_API_KEY ;
529- }
530- if ( process . env . ELEVENLABS_VOICE_ID ) {
531- if ( ! config . elevenlabs ) config . elevenlabs = { } ;
532- config . elevenlabs . voice_id = process . env . ELEVENLABS_VOICE_ID ;
533- }
534-
535- if ( process . env . JIRA_BASE_URL || process . env . JIRA_EMAIL || process . env . JIRA_API_TOKEN ) {
536- if ( ! config . jira ) config . jira = { } ;
537- if ( process . env . JIRA_BASE_URL ) config . jira . base_url = process . env . JIRA_BASE_URL ;
538- if ( process . env . JIRA_EMAIL ) config . jira . email = process . env . JIRA_EMAIL ;
539- if ( process . env . JIRA_API_TOKEN ) config . jira . api_token = process . env . JIRA_API_TOKEN ;
540- }
541-
542- // Claude Code auth credentials from env
543- if ( process . env . CLAUDE_CODE_API_KEY ) {
544- config . claude_code . api_key = process . env . CLAUDE_CODE_API_KEY ;
545- }
546- if ( process . env . CLAUDE_CODE_OAUTH_TOKEN ) {
547- config . claude_code . oauth_token = process . env . CLAUDE_CODE_OAUTH_TOKEN ;
548- }
549-
550- // LinkedIn token-based auth from env
551- if ( process . env . LINKEDIN_ACCESS_TOKEN ) {
552- if ( ! config . linkedin ) config . linkedin = { } ;
553- config . linkedin . access_token = process . env . LINKEDIN_ACCESS_TOKEN ;
554- }
555- if ( process . env . LINKEDIN_PERSON_URN ) {
556- if ( ! config . linkedin ) config . linkedin = { } ;
557- config . linkedin . person_urn = process . env . LINKEDIN_PERSON_URN ;
558- }
559-
560- // X (Twitter) OAuth 1.0a credentials from env
561- if ( process . env . X_CONSUMER_KEY ) {
562- if ( ! config . x ) config . x = { } ;
563- config . x . consumer_key = process . env . X_CONSUMER_KEY ;
564- }
565- if ( process . env . X_CONSUMER_SECRET ) {
566- if ( ! config . x ) config . x = { } ;
567- config . x . consumer_secret = process . env . X_CONSUMER_SECRET ;
568- }
569- if ( process . env . X_ACCESS_TOKEN ) {
570- if ( ! config . x ) config . x = { } ;
571- config . x . access_token = process . env . X_ACCESS_TOKEN ;
572- }
573- if ( process . env . X_ACCESS_TOKEN_SECRET ) {
574- if ( ! config . x ) config . x = { } ;
575- config . x . access_token_secret = process . env . X_ACCESS_TOKEN_SECRET ;
521+ // Declarative env → config mapping for integration credentials.
522+ // Each entry: [ENV_VAR_NAME, configSection, configKey]
523+ const ENV_TO_CONFIG = [
524+ [ 'GITHUB_TOKEN' , 'github' , 'token' ] ,
525+ [ 'ELEVENLABS_API_KEY' , 'elevenlabs' , 'api_key' ] ,
526+ [ 'ELEVENLABS_VOICE_ID' , 'elevenlabs' , 'voice_id' ] ,
527+ [ 'JIRA_BASE_URL' , 'jira' , 'base_url' ] ,
528+ [ 'JIRA_EMAIL' , 'jira' , 'email' ] ,
529+ [ 'JIRA_API_TOKEN' , 'jira' , 'api_token' ] ,
530+ [ 'CLAUDE_CODE_API_KEY' , 'claude_code' , 'api_key' ] ,
531+ [ 'CLAUDE_CODE_OAUTH_TOKEN' , 'claude_code' , 'oauth_token' ] ,
532+ [ 'LINKEDIN_ACCESS_TOKEN' , 'linkedin' , 'access_token' ] ,
533+ [ 'LINKEDIN_PERSON_URN' , 'linkedin' , 'person_urn' ] ,
534+ [ 'X_CONSUMER_KEY' , 'x' , 'consumer_key' ] ,
535+ [ 'X_CONSUMER_SECRET' , 'x' , 'consumer_secret' ] ,
536+ [ 'X_ACCESS_TOKEN' , 'x' , 'access_token' ] ,
537+ [ 'X_ACCESS_TOKEN_SECRET' , 'x' , 'access_token_secret' ] ,
538+ ] ;
539+
540+ for ( const [ envKey , section , key ] of ENV_TO_CONFIG ) {
541+ if ( process . env [ envKey ] ) {
542+ if ( ! config [ section ] ) config [ section ] = { } ;
543+ config [ section ] [ key ] = process . env [ envKey ] ;
544+ }
576545 }
577546
578547 return config ;
0 commit comments