diff --git a/src/app.ts b/src/app.ts index a57cff5..5a0bef4 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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'); } @@ -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}!`); })(); diff --git a/src/endpoints/index.ts b/src/endpoints/index.ts new file mode 100644 index 0000000..e10e25b --- /dev/null +++ b/src/endpoints/index.ts @@ -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'); + }); +}; diff --git a/src/events/webhook-endpoint.ts b/src/endpoints/webhook-endpoint.ts similarity index 100% rename from src/events/webhook-endpoint.ts rename to src/endpoints/webhook-endpoint.ts diff --git a/src/installation-store/index.ts b/src/installation-store/index.ts index f8d1aa9..c945d4c 100644 --- a/src/installation-store/index.ts +++ b/src/installation-store/index.ts @@ -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');