Skip to content

Commit

Permalink
chore: redirect from / to /slack/install
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Dec 20, 2023
1 parent e22c39f commit 45c4e08
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import { registerLinkCommand } from './commands/link/link.js';
import { registerBlockCommand } from './commands/block/block.js';
import { registerAddressCommand } from './commands/address/address.js';
import { registerWelcomeMessage } from './events/welcome-message.js';
import { registerWebhookEndpoint } from './events/webhook-endpoint.js';
import { registerWebhookEndpoint } from './endpoints/webhook-endpoint.js';
import { registerAccountCommand } from './commands/account/account.js';
import { registerPoolCommand } from './commands/pool/pool.js';
import { registerBlockfrostHelpCommand } from './commands/blockfrost-help/blockfrost-help.js';
import { registerRootEndpoint } from './endpoints/index.js';
const { App, ExpressReceiver, LogLevel } = bolt;

const port = Number(process.env.PORT) || 3000;

if (!process.env.SLACK_SIGNING_SECRET) {
throw Error('Set env variable SLACK_SIGNING_SECRET');
}
Expand Down Expand Up @@ -63,10 +66,11 @@ registerBlockfrostHelpCommand(app);

registerWelcomeMessage(app);
registerWebhookEndpoint(expressReceiver);
registerRootEndpoint(expressReceiver);

(async () => {
// Start your app
await app.start(Number(process.env.PORT) || 3000);
await app.start(port);

console.log('⚡️ Bolt app is running!');
console.log(`⚡️ Blockfrost for Slack is running on port ${port}!`);
})();
8 changes: 8 additions & 0 deletions src/endpoints/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ExpressReceiver } from '@slack/bolt';
import { Request, Response } from 'express-serve-static-core';

export const registerRootEndpoint = (expressReceiver: ExpressReceiver) => {
expressReceiver.router.get('/', async (_req: Request, res: Response) => {
return res.redirect('/slack/install');
});
};
File renamed without changes.
4 changes: 2 additions & 2 deletions src/installation-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export default class BlockfrostInstallationStore implements InstallationStore {
}

if (installQuery.isEnterpriseInstall && installQuery.enterpriseId !== undefined) {
logger?.debug('deleting org installation');
logger?.debug(`deleting org installation ${installQuery.enterpriseId}`);
return await dbStore.deleteInstallation(installQuery.enterpriseId);
}
if (installQuery.teamId !== undefined) {
logger?.debug('deleting single team installation');
logger?.debug(`deleting single team installation ${installQuery.teamId}`);
return await dbStore.deleteInstallation(installQuery.teamId);
} else {
throw new Error('Failed to delete installation');
Expand Down

0 comments on commit 45c4e08

Please sign in to comment.