Skip to content

Commit

Permalink
feat: Add options for apiOptions to PulumiCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre committed Sep 28, 2021
1 parent e86f003 commit 3036dae
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/index.ts
Expand Up @@ -2,7 +2,7 @@ import { FastifyPluginAsync } from 'fastify';
import * as phh from 'pubsub-http-handler';
import { handlePubSubMessage } from 'pubsub-http-handler';
import { makeHandler } from './handler';
import { SlackConfig, SlackRequestType } from './types';
import { SlackApiOptions, SlackConfig, SlackRequestType } from './types';
export { makeHandler } from './handler';

export const makePubSubCloudFunctions = (
Expand All @@ -26,8 +26,17 @@ export const makePubSubServer = (

export type PulumiCallbackFun = (message: any) => Promise<any>;

export interface PulumiCallbackOptions {
/**
* These configuration options are only required when type is set to
* `api`.
*/
apiOptions?: Omit<SlackApiOptions, 'token'>;
}

export const makePulumiCallback = (
type: SlackRequestType,
options: PulumiCallbackOptions = {},
): PulumiCallbackFun => {
if (type === 'api') {
return async (message: any): Promise<void> => {
Expand All @@ -40,7 +49,7 @@ export const makePulumiCallback = (
message,
handler: makeHandler({
type: 'api',
apiOptions: { token },
apiOptions: { token, ...options.apiOptions },
}),
parseJson: true,
});
Expand Down

0 comments on commit 3036dae

Please sign in to comment.