1.0.13 • Published 5 months ago

@jswork/hot-config-service v1.0.13

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

hot-config-service

A lightweight JavaScript class for dynamic configurations.

version license size download

installation

yarn add @jswork/hot-config-service

usage

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.

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago