本文整理汇总了TypeScript中core/config/config-loader.ConfigProvider类的典型用法代码示例。如果您正苦于以下问题:TypeScript ConfigProvider类的具体用法?TypeScript ConfigProvider怎么用?TypeScript ConfigProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigProvider类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
this.asyncMiddleware(async (req, res) => {
if (process.IS_PRO_ENABLED) {
return res.send('Botpress Pro is already enabled.')
}
await this.configProvider.mergeBotpressConfig({ pro: { enabled: true } })
res.send('Enabled successfully')
})
示例2:
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)
})
示例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)
})