Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #897 Add built-in fields to Context object type #902

Merged
merged 2 commits into from
Apr 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/types/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,40 @@ export interface Middleware<Args> {
(args: Args & AllMiddlewareArgs): Promise<void>;
}

export interface Context extends StringIndexed {}
/**
* Context object, which provides contextual information associated with an incoming requests.
* You can set any other custom attributes in global middleware as long as the key does not conflict with others.
*/
export interface Context extends StringIndexed {
/**
* A bot token, which starts with `xoxb-`.
* This value can be used by `say` (preferred over userToken),
*/
botToken?: string;
/**
* A bot token, which starts with `xoxp-`.
* This value can be used by `say` (overridden by botToken),
*/
userToken?: string;
/**
* This app's bot ID in the installed workspace.
* This is required for `ignoreSelf` global middleware.
* see also: https://github.com/slackapi/bolt-js/issues/874
*/
botId?: string;
/**
* This app's bot user ID in the installed workspace.
* This value is optional but allows `ignoreSelf` global middleware be more filter more than just message events.
*/
botUserId?: string;
/**
* Workspace ID.
*/
teamId?: string;
/**
* Enterprise Grid Organization ID.
*/
enterpriseId?: string;
}

export type NextFn = () => Promise<void>;