本文整理匯總了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)
})