1.3.0 • Published 10 months ago

@microfox/slack-web-tiny v1.3.0

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

Slack Web Tiny SDK

A lightweight, type-safe SDK for interacting with the Slack Web API.

Installation

npm install @microfox/slack-web-tiny

Usage

import { createSlackSDK } from '@microfox/slack-web-tiny';

// Initialize the SDK with your Slack bot token
const slackSDK = createSlackSDK({
  botToken: process.env.SLACK_BOT_TOKEN ?? 'xoxb-your-bot-token',
  authType: 'header',
  baseUrl: 'https://slack.com/api',
});

API Reference

createSlackSDK(config: SlackSDKConfig)

Creates a new instance of the Slack SDK.

Config Options

  • botToken (string, required): Your Slack bot user OAuth token
  • authType ('header' | 'query', optional): Authentication method (defaults to 'header')
  • baseUrl (string, optional): Override the default Slack API URL (defaults to 'https://slack.com/api')

Error Handling

The SDK uses Zod for runtime type validation and will throw errors if:

  • The message payload doesn't match the expected schema
  • The API response doesn't match the expected schema
  • The API request fails

Example:

try {
  const response = await slackSDK.sendMessage({
    channel: 'C1234567890', // Channel ID
    text: 'Hello world',
  });
  console.log('Message sent:', response);
} catch (error) {
  console.error('Failed to send message:', error);
}
1.3.0

10 months ago

1.2.5

11 months ago

1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.2.0

12 months ago

1.1.0

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago