我正在尝试在 @nestjs/core 应用程序中添加 @slack/bolt 库。
我正在这样做
export class AppModule implements NestModule{
configure(consumer: MiddlewareConsumer): any {
const receiver = new ExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET,
endpoints: '/'
});
const boltApp = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver,
});
consumer
.apply(receiver.router)
.forRoutes('/slack/events');
}
}
该代码有效并接受到/slack/events的 POST,但请求因超时而退出。
有人有同样的问题吗?
如果@slack/bolt 框架被注入到 Nest 初始化中,一切正常
//main.ts
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: logLevels,
});
const receiver = new ExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET,
endpoints: '/',
});
const boltApp = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver,
logLevel: BoltLogLevel.DEBUG,
});
app.use('/slack/events', receiver.app);
await app.listen(3000);
}