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 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
23 changes: 13 additions & 10 deletions src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,20 @@ export default class App {
this.listeners = [];

// Check for required arguments of ExpressReceiver
if (signingSecret !== undefined) {
this.receiver = new ExpressReceiver({ signingSecret, logger, endpoints });
} else if (receiver === undefined) {
// Check for custom receiver
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 {
if (receiver !== undefined) {
this.receiver = receiver;
} else {
// No custom receiver
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 {
// Create default ExpressReceiver
this.receiver = new ExpressReceiver({ signingSecret, logger, endpoints });
}
}

// Subscribe to messages and errors from the receiver
Expand Down