MCPcopy
hub / github.com/slackapi/node-slack-sdk / constructor

Method constructor

packages/web-api/src/WebClient.ts:85–132  ·  view source on GitHub ↗

* @param token - An API token to authenticate/authorize with Slack (usually start with `xoxp`, `xoxb`)

(token?: string, {
    slackApiUrl = 'https://slack.com/api/',
    logger = undefined,
    logLevel = LogLevel.INFO,
    maxRequestConcurrency = 3,
    retryConfig = retryPolicies.tenRetriesInAboutThirtyMinutes,
    agent = undefined,
    tls = undefined,
    rejectRateLimitedCalls = false,
    headers = {},
  }: WebClientOptions = {})

Source from the content-addressed store, hash-verified

83 * @param token - An API token to authenticate/authorize with Slack (usually start with `xoxp`, `xoxb`)
84 */
85 constructor(token?: string, {
86 slackApiUrl = 'https://slack.com/api/',
87 logger = undefined,
88 logLevel = LogLevel.INFO,
89 maxRequestConcurrency = 3,
90 retryConfig = retryPolicies.tenRetriesInAboutThirtyMinutes,
91 agent = undefined,
92 tls = undefined,
93 rejectRateLimitedCalls = false,
94 headers = {},
95 }: WebClientOptions = {}) {
96 super();
97 this.token = token;
98 this.slackApiUrl = slackApiUrl;
99
100 this.retryConfig = retryConfig;
101 this.requestQueue = new PQueue({ concurrency: maxRequestConcurrency });
102 // NOTE: may want to filter the keys to only those acceptable for TLS options
103 this.tlsConfig = tls !== undefined ? tls : {};
104 this.rejectRateLimitedCalls = rejectRateLimitedCalls;
105
106 // Logging
107 this.logger = getLogger(WebClient.loggerName, logLevel, logger);
108
109 this.axios = axios.create({
110 baseURL: slackApiUrl,
111 headers: Object.assign(
112 {
113 'User-Agent': getUserAgent(),
114 },
115 headers,
116 ),
117 httpAgent: agent,
118 httpsAgent: agent,
119 transformRequest: [this.serializeApiCallOptions.bind(this)],
120 validateStatus: () => true, // all HTTP status codes should result in a resolved promise (as opposed to only 2xx)
121 maxRedirects: 0,
122 // disabling axios' automatic proxy support:
123 // axios would read from envvars to configure a proxy automatically, but it doesn't support TLS destinations.
124 // for compatibility with https://api.slack.com, and for a larger set of possible proxies (SOCKS or other
125 // protocols), users of this package should use the `agent` option to configure a proxy.
126 proxy: false,
127 });
128 // serializeApiCallOptions will always determine the appropriate content-type
129 delete this.axios.defaults.headers.post['Content-Type'];
130
131 this.logger.debug('initialized');
132 }
133
134 /**
135 * Generic method for calling a Web API method

Callers

nothing calls this directly

Calls 3

getLoggerFunction · 0.90
getUserAgentFunction · 0.90
debugMethod · 0.65

Tested by

no test coverage detected