@dchighs/dc-config

中文文档
0.1.183发布于 2026/11/12MITTypeScriptESM + CJS近 30 天下载 4400

A library to handle configuration for Dragon City.

原始使用文档
文档目录7 节
  1. 📦 Installation
  2. 🚀 Usage
  3. Fetching configuration for specific parameters
  4. Loading a saved configuration from a file
  5. Fetching a raw configuration from a URL
  6. 🤝 Contributing
  7. 📝 License

@dchighs/dc-config

⚠️ Note: Don't ask me how to get your URL, Auth Token, or User ID; I won't answer you. If you don't know how to use this, it's because you shouldn't.

@dchighs/dc-config is a package for accessing game configuration data from Dragon City (this is not an official SocialPoint library; it is fan-made).

📦 Installation

Installation is straightforward—simply use your preferred package manager. Here is an example using NPM:

npm i @dchighs/dc-config

🚀 Usage

Buy Me A Coffee

Fetching configuration for specific parameters

To create a Config instance, you need to provide credentials or use the static .create() method by providing the necessary parameters:

import { Config, ConfigLanguage, ConfigPlatform, ConfigFilter } from "@dchighs/dc-config"

;(async () => {
    const userId = process.env.USER_ID
    const authToken = process.env.AUTH_TOKEN
    const url = process.env.URL

    const config = await Config.create({
        url: url,
        userId: userId,
        authToken: authToken,
        language: ConfigLanguage.Turkish, // optional - "en" is default
        platform: ConfigPlatform.Android, // optional - "ios" is default
        filter: [ConfigFilter.Items] // optional - undefined is default
    })

    const data = config.data

    console.log(data)
})();

Loading a saved configuration from a file

If you have a saved JSON file containing configuration data and want to load it to perform operations using the class, you can do it as follows:

import { Config, ConfigLanguage, ConfigPlatform, GameConfigDto } from "@dchighs/dc-config"
import fs from "node:fs"

;(async () => {
    const filePath = "config.json"
    const contentString = await fs.promises.readFile(filePath, { encoding: "utf-8" })
    const data = JSON.parse(contentString) as GameConfigDto

    const config = new Config({
        language: ConfigLanguage.Turkish,
        platform: ConfigPlatform.Android,
        data: data
    })
})();

Fetching a raw configuration from a URL

If you have a full raw JSON file and want to fetch it and filter specific keys:

import { Config, ConfigFilter, ConfigLanguage } from "@dchighs/dc-config"

;(async () => {
    const rawUrl = "https://example.com/config.json"
    
    // Using createRaw to get a Config instance
    const config = await Config.createRaw({
        url: rawUrl,
        filter: [ConfigFilter.Items],
        language: ConfigLanguage.English
    })

    // Or using fetchRaw to get just the data (GameConfigDto)
    const data = await Config.fetchRaw({
        url: rawUrl,
        filter: [ConfigFilter.Items]
    })
})();

🤝 Contributing

  • Want to contribute? Follow these steps:
  • Fork the repository.
  • Create a new branch (git checkout -b feature-new).
  • Commit your changes (git commit -m 'Add new feature').
  • Push to the branch (git push origin feature-new).
  • Open a Pull Request.

📝 License

This project is licensed under the MIT License.

版本与发布记录

@dchighs/dc-config 共发布 100 个版本,首次发布于 2026/01/08;过去 12 个月发布了 100 个版本。

版本发布日期距今
0.1.183latest2026/11/12今天
0.1.1822026/11/111 天前
0.1.1812026/11/101 天前
0.1.1802026/11/084 天前
0.1.1792026/11/075 天前
0.1.1782026/11/066 天前

关于 @dchighs/dc-config 的常见问题

@dchighs/dc-config 是什么?

A library to handle configuration for Dragon City.

如何安装 @dchighs/dc-config?

在项目目录运行 npm install @dchighs/dc-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@dchighs/dc-core(^0.4.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dchighs/dc-config 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dchighs/dc-config 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dchighs/dc-config 可以商用吗?

@dchighs/dc-config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dchighs/dc-config 的下载量有多少?

根据 npm 官方下载统计,@dchighs/dc-config 在 2026/10/12 – 2026/11/10 这 30 天内被下载 4,400 次,日均约 147 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dchighs/dc-config 还在维护吗?

最新版本 0.1.183 发布于 2026/11/12(今天);至今共发布 100 个版本,其中过去 12 个月发布了 100 个;首次发布于 2026/01/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。