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 🙏

© 2025 – Pkg Stats / Ryan Hefner

longtan

v0.12.8

Published

Server Side Framework via Koa

Readme

Longtan

基於 Koa 的伺服器端框架,提供完整的企業級應用程式開發解決方案。

概述

Longtan 是一個全功能的 Node.js 伺服器端框架,整合了多種企業級功能,包括資料庫支援、訊息佇列、即時通訊整合、機器學習模型支援以及分析工具等。

特色功能

  • 多資料庫支援: MongoDB、MySQL、Redis、InfluxDB
  • 訊息佇列: Bull、Bee Queue、Agenda、AMQP
  • 即時通訊整合: 釘釘、飛書、微信、Slack
  • 機器學習支援: LangChain 整合,支援 OpenAI、Anthropic、AWS
  • 分析工具: 內建分析引擎和資料處理工具
  • 進程管理: 叢集模式支援,優雅關機機制
  • 開發工具: 豐富的命令行工具和除錯支援

安裝

npm install longtan
# 或
yarn add longtan

快速開始

const longtan = require('longtan');

// 啟動應用程式
longtan.launch({
  title: 'MyApp',
  subTitle: ['Version 1.0.0', 'Enterprise Ready']
});

專案結構

longtan/
├── bin/                    # 命令行工具
│   ├── curl.js            # HTTP 請求工具
│   ├── entry.sh           # 應用程式入口腳本
│   ├── exec.sh            # 執行腳本
│   ├── restart.sh         # 重啟腳本
│   ├── stop.sh            # 停止腳本
│   └── yarn.sh            # Yarn 包管理腳本
├── lib/                   # 核心程式庫
│   ├── logic/            # 業務邏輯層
│   │   ├── entity/       # 實體定義
│   │   ├── generic_analytics/ # 通用分析工具
│   │   │   ├── analytics/ # 分析引擎
│   │   │   └── storage/   # 儲存層
│   │   ├── bit_analytics.js # 位元分析邏輯
│   │   ├── bit_batch.js     # 批次處理邏輯
│   │   ├── dingtalk.js      # 釘釘整合
│   │   ├── feishu.js        # 飛書整合
│   │   ├── mongo.js         # MongoDB 邏輯
│   │   ├── multi_agent.js   # 多代理系統
│   │   ├── slack.js         # Slack 整合
│   │   └── wechat.js        # 微信整合
│   ├── manager/          # 管理器層
│   │   ├── job.js        # 任務管理器
│   │   ├── route.js      # 路由管理器
│   │   └── thread.js     # 執行緒管理器
│   ├── model/            # 資料模型層
│   │   ├── agenda.js     # Agenda 佇列模型
│   │   ├── amqp.js       # AMQP 訊息佇列
│   │   ├── dingtalk.js   # 釘釘 API 模型
│   │   ├── feishu.js     # 飛書 API 模型
│   │   ├── influxdb.js   # InfluxDB 時序資料庫
│   │   ├── ioredis.js    # Redis 模型 (ioredis)
│   │   ├── llm.js        # 大語言模型整合
│   │   ├── mongo.js      # MongoDB 模型
│   │   ├── mysql.js      # MySQL 模型
│   │   ├── queue_redis_bee.js  # Bee Queue
│   │   ├── queue_redis_bull.js # Bull Queue
│   │   ├── slack.js      # Slack API 模型
│   │   ├── wechat.js     # 微信 API 模型
│   │   └── wechat_pay.js # 微信支付模型
│   ├── utility/          # 工具程式庫
│   │   ├── encryption_handler.js # 加密處理
│   │   ├── error_message.js      # 錯誤訊息管理
│   │   ├── id_card.js           # 身分證驗證工具
│   │   ├── logger.js            # 日誌工具
│   │   ├── logger_koa_bunyan.js # Koa Bunyan 日誌
│   │   ├── performance.js       # 效能監控
│   │   ├── queue_util.js        # 佇列工具
│   │   ├── shutdown_controller.js # 關機控制器
│   │   └── strategy.js          # 策略模式工具
│   ├── master.js         # 主進程管理
│   ├── thread-util.js    # 執行緒工具
│   ├── util.js           # 通用工具
│   └── worker-util.js    # Worker 工具
├── test/                 # 測試檔案
├── examples/             # 範例程式碼
├── docs/                 # 文件
├── index.js              # 主入口檔案
├── gulpfile.js           # Gulp 建置腳本
├── package.json          # 套件配置
└── tsconfig.json         # TypeScript 配置

核心模組說明

資料庫支援

  • MongoDB: 完整的 MongoDB 整合,支援連接池和事務
  • MySQL: MySQL 資料庫支援,包含連接管理
  • Redis: 雙重 Redis 支援 (ioredis 和 node_redis)
  • InfluxDB: 時序資料庫支援,適合指標和分析資料

訊息佇列

  • Bull Queue: 基於 Redis 的強大佇列系統
  • Bee Queue: 輕量級 Redis 佇列
  • Agenda: MongoDB 基礎的任務排程器
  • AMQP: RabbitMQ 等 AMQP 協議支援

即時通訊整合

  • 釘釘 (DingTalk): 企業即時通訊整合
  • 飛書 (Feishu): 字節跳動企業通訊平台
  • 微信 (WeChat): 微信 API 和微信支付整合
  • Slack: Slack 工作空間整合

AI/ML 支援

  • LangChain: 大語言模型鏈式處理
  • OpenAI: GPT 模型整合
  • Anthropic: Claude 模型支援
  • AWS: Amazon AI 服務整合
  • 多代理系統: 支援複雜的 AI 代理互動

命令行工具

Longtan 提供豐富的命令行工具:

# 重啟應用程式
longtan_restart

# 停止應用程式
longtan_stop

# 執行命令
longtan_exec

# 帶顏色輸出的執行
longtan_colorful_exec

# 外部執行
longtan_outside_exec

# 查看日誌
longtan_print_logs

# HTTP 請求工具
longtan_curl

# Yarn 操作
longtan_yarn

開發指令

# 程式碼格式化
npm run prettier

# 程式碼檢查
npm run lint

# 運行測試
npm run test

# 監控模式測試
npm run test:watch

# 產生測試覆蓋率報告
npm run test:coverage

# 壓縮和編譯
npm run compress

配置說明

應用程式支援環境變數配置,預設環境為 development。支援叢集模式部署,可以透過配置檔案管理多個叢集實例。

叢集配置範例

{
  "cluster": {
    "web": {
      "name": "WebServer",
      "enabled": true,
      "debug_enabled": true,
      "debug_port": 9229
    }
  },
  "general": {
    "graceful_shutdown": 10000
  }
}

進階功能

優雅關機

內建優雅關機機制,確保所有進程和連接正確關閉。

效能監控

整合效能監控工具,可以追蹤應用程式效能指標。

分析引擎

內建通用分析引擎,支援資料處理和統計分析。

加密支援

提供加密處理工具,確保敏感資料安全。

授權條款

MIT License

作者

Paul Lv [email protected]

版本

目前版本: 0.12.4


更多詳細資訊請參考 /docs 目錄下的文件或查看 /examples 目錄中的範例程式碼。