npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@blued-core/bc-qconf

v1.0.5

Published

support baisc command and mysql and redis configuration

Downloads

14

Readme

bc-qconf

封装基于 child_process 调用本地命令方式的 qconf 获取库。兼容现有大部分使用方式。并支持 ts 类型校验及类型提示。

使用方式

包含的 API 对应 qconf 命令的 getConf、getHost、getAllHost、getBatchKeys 以及拓展的 getRedisConf、getMysqlConf 内容。在 ts 语法下支持参数提示,可自动提示所配置的 key 名。

示例

import { BcQconf, QConfigs } from '@blued/bc-qconf';

const qconfs: QConfigs<'conf' | 'host' | 'allHost' | 'mysql' | 'redis'> = {
  conf: {
    qconf: '/blued/backend/umem/qconf_test_cc/test_content'
  },
  host: {
    qconf: '/blued/backend/umem/qconf_test_cc'
  },
  allHost: {
    qconf: '/blued/backend/umem/qconf_test_cc'
  },
  mysql: {
    qconf: '/blued/backend/umem/qconf_test_cc',
    database: 'blued',
    modelPath: '/abc',
  },
  redis: {
    qconf: '/blued/backend/umem/qconf_test_cc'
  }
}

const qc = new BcQconf(qConfs)

// 返回 path 本身的节点值。如:{"activity_id":316,"start_time":"20231208","end_time":"20231214"}
qc.getConf('conf')

// 返回 path 下第一个节点值为 0 的节点名称。如:100.100.100.100:90
qc.getHost('host')

// 返回 path 下所有节点值为 0 的节点名称。如:[ '100.100.100.100:90', '123.123.123.123:80' ]
qc.getAllHost('allHost')

// 返回 path 下所有节点名称。如:[ '100.100.100.100:90', '123.123.123.123:80', 'database', 'master', 'password', 'slave', 'test_content', 'username' ]
qc.getBatchKeys('allHost')

// 是 getHost 的 alias
qc.getApi('host')

// 返回 path 下所有节点名称。支持 password 参数
// 如:{ host: '100.100.100.100', port: '90', password: 'wo_is_pwd' }
qc.getRedisConf('redis')

// 以 mysql 配置形式返回值。
// 如:{
  master: { host: '111.111.111.111', port: '80' },
  slave: [
    { host: '120.120.120.120', port: '100' },
    { host: '121.121.121.121', port: '101' }
  ],
  username: 'chisecc',
  password: 'wo_is_pwd',
  database: 'blued',
  modelPath: '/abc'
}
qc.getMysqlConf('mysql')

配置参数

{
  // qconf 读取路径配置。注意:必须包含 qconf 属性
  configs: { [key: string]: { qconf: string, database?: string, modelPath?: string } },

  // 表示要读区的配置的源(一般不用配置,按本地配置走)。如:production 则读取线上配置
  // flag 的值对应,qconf 下配置文件 idc.conf 内的名称
  flag: string
}

Todo

Changelog

1.0.4 (2023-12-25)

  • feat: 调整 ts 语法定义,新增 QConfigs 对象定义类型

1.0.3 (2023-12-23)

  • fix: qc.getRedisConf() 在部分场景下异常

1.0.2 (2023-12-22)

  • feat: 新增 QconfError 错误类型
  • feat: 调整 spawnSync 命令执行时,错误处理逻辑