本文整理汇总了TypeScript中core/config/config-loader.ConfigProvider.getBotpressConfig方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ConfigProvider.getBotpressConfig方法的具体用法?TypeScript ConfigProvider.getBotpressConfig怎么用?TypeScript ConfigProvider.getBotpressConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core/config/config-loader.ConfigProvider
的用法示例。
在下文中一共展示了ConfigProvider.getBotpressConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
this.asyncMiddleware(async (req, res, next) => {
const moduleName = req.params.moduleName
const config = await this.configProvider.getBotpressConfig()
const module = config.modules.find(x => x.location.endsWith(moduleName))
if (module) {
await this.moduleLoader.reloadModule(module.location, moduleName)
return res.sendStatus(200)
}
res.sendStatus(404)
})
示例2:
this.asyncMiddleware(async (req, res) => {
const { fromTime, toTime } = req.body
if (!_.isNumber(fromTime) || !_.isNumber(toTime)) {
return res.sendStatus(400)
}
const config = await this.configProvider.getBotpressConfig()
if (!_.get(config, 'pro.alerting.enabled', false)) {
return res.send(undefined)
}
res.send(await this.alertingService.getIncidents(fromTime, toTime))
})
示例3: setTimeout
this.asyncMiddleware(async (req, res) => {
const user = req.tokenUser!.email
const config = await this.configProvider.getBotpressConfig()
if (!config.allowServerReboot) {
this.logger.warn(`User ${user} requested a server reboot, but the feature is disabled.`)
return res.status(400).send(`Rebooting the server is disabled in the botpress.config.json file`)
}
this.logger.info(`User ${user} requested a server reboot`)
res.sendStatus(200)
// Timeout is only to allow the response to reach the asking user
setTimeout(() => {
spawn(process.argv[0], process.argv.slice(1), {
detached: true,
stdio: 'inherit'
}).unref()
process.exit()
}, 100)
})