https://github.com/afeiship/hot-config-service
A lightweight JavaScript class for dynamic configurations.
https://github.com/afeiship/hot-config-service
config hot service
Last synced: 3 months ago
JSON representation
A lightweight JavaScript class for dynamic configurations.
- Host: GitHub
- URL: https://github.com/afeiship/hot-config-service
- Owner: afeiship
- License: mit
- Created: 2018-06-18T07:45:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-18T13:54:50.000Z (almost 2 years ago)
- Last Synced: 2025-02-07T12:31:45.906Z (8 months ago)
- Topics: config, hot, service
- Language: TypeScript
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# hot-config-service
> A lightweight JavaScript class for dynamic configurations.[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]## installation
```shell
yarn add @jswork/hot-config-service
```## usage
```js
import HotConfigService from '@jswork/hot-config-service';const hotConfig = new HotConfigService({
// 环境配置,可以设置多个环境的API地址
envs: {
'beta': 'https://student-api.beta.saybot.net',
'production': 'https://student-api.alo7.com'
},
// 当前环境
env: 'beta',
// API路径,可选,默认为空
path: '/api/v2/configurations/',
// 请求超时时间,可选,默认为30秒
timeout: 30000,
// 当请求失败时的默认配置,可选
fallback: {}
});// 获取配置
await hotConfig.fetch();// 获取整个配置对象
const config = hotConfig.get();// 获取特定路径的配置值
const value = hotConfig.get('some.nested.key');
```## license
Code released under [the MIT license](https://github.com/afeiship/hot-config-service/blob/master/LICENSE.txt).[version-image]: https://img.shields.io/npm/v/@jswork/hot-config-service
[version-url]: https://npmjs.org/package/@jswork/hot-config-service[license-image]: https://img.shields.io/npm/l/@jswork/hot-config-service
[license-url]: https://github.com/afeiship/hot-config-service/blob/master/LICENSE.txt[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/hot-config-service
[size-url]: https://github.com/afeiship/hot-config-service/blob/master/dist/index.min.js[download-image]: https://img.shields.io/npm/dm/@jswork/hot-config-service
[download-url]: https://www.npmjs.com/package/@jswork/hot-config-service