@@ -24,26 +24,35 @@ export class Twitter {
2424 this . accessTokenSecret = keys . accessTokenSecret || process . env . ACCESS_TOKEN_SECRET
2525
2626 // a client for v1.1 endpoints
27- this . twit = new Twit ( {
28- consumer_key : this . consumerKey ,
29- consumer_secret : this . consumerSecret ,
30- access_token : this . accessToken ,
31- access_token_secret : this . accessTokenSecret
32- } )
27+ if ( this . consumerKey && this . consumerSecret && this . accessToken && this . accessTokenSecret ) {
28+ this . twit = new Twit ( {
29+ consumer_key : this . consumerKey ,
30+ consumer_secret : this . consumerSecret ,
31+ access_token : this . accessToken ,
32+ access_token_secret : this . accessTokenSecret
33+ } )
3334
34- // a client for v2 endpoints
35- this . twitterV2 = new TwitterV2 ( {
36- consumer_key : this . consumerKey ,
37- consumer_secret : this . consumerSecret ,
38- access_token_key : this . accessToken ,
39- access_token_secret : this . accessTokenSecret
40- } )
35+ // a client for v2 endpoints
36+ this . twitterV2 = new TwitterV2 ( {
37+ consumer_key : this . consumerKey ,
38+ consumer_secret : this . consumerSecret ,
39+ access_token_key : this . accessToken ,
40+ access_token_secret : this . accessTokenSecret
41+ } )
42+
43+ } else {
44+ log . warn ( 'not configuring user client for v1.1 and v2 endpoints since not all keys are present' )
45+ }
4146
4247 // a app auth client for v2 endpoints
43- this . twitterV2app = new TwitterV2 ( {
44- consumer_key : this . consumerKey ,
45- consumer_secret : this . consumerSecret ,
46- } )
48+ if ( this . consumerKey && this . consumerSecret ) {
49+ this . twitterV2app = new TwitterV2 ( {
50+ consumer_key : this . consumerKey ,
51+ consumer_secret : this . consumerSecret ,
52+ } )
53+ } else {
54+ log . warn ( 'unable to configure app client for v2 endpoint since not all keys are present' )
55+ }
4756 }
4857
4958 getPlaces ( ) {
0 commit comments