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

Respect custom receivers #271

Merged
merged 3 commits into from
Oct 3, 2019
Merged
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default class App {
this.listeners = [];

// Check for required arguments of ExpressReceiver
if (signingSecret !== undefined) {
if (signingSecret !== undefined && receiver === undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change these lines to make it more easy-to-understand:

// Check for required arguments of ExpressReceiver
if (signingSecret !== undefined && receiver === undefined) {
    this.receiver = new ExpressReceiver({ signingSecret, logger, endpoints });
} else if (receiver === undefined) {
    // Check for custom receiver

How about this?

// Check for required arguments of ExpressReceiver
if (receiver !== undefined) {
    // NOTE: signingSecret would be ignored in this case
    this.receiver = receiver;
} else {
    // no custom receiver given here
    if (signingSecret === undefined) {
        throw errorWithCode(
            'Signing secret not found, so could not initialize the default receiver. ' +
            'Set a signing secret or use a custom receiver.',
            ErrorCode.AppInitializationError,
        );
    } else {
        this.receiver = new ExpressReceiver({ signingSecret, logger, endpoints });
    }
}

this.receiver = new ExpressReceiver({ signingSecret, logger, endpoints });
} else if (receiver === undefined) {
// Check for custom receiver
Expand Down