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 🙏

© 2026 – Pkg Stats / Ryan Hefner

express-hale

v1.4.8

Published

🚀 Interactive Express.js scaffold CLI with comprehensive error handling, TypeScript/JavaScript, database integrations, Git Flow, and development tools

Readme

Express Hale CLI

🚀 交互式 Express.js 脚手架 CLI,支持 TypeScript/JavaScript、数据库集成、全面的错误处理和开发工具。

✨ 特性

  • 语言支持: 支持 TypeScript 或 JavaScript
  • 数据库集成: 支持 MySQL、MongoDB、Redis 数据库,预配置连接
  • 开发工具: 集成 ESLint、Prettier 和自动格式化
  • 测试框架: 支持 Jest 或 Mocha 测试框架
  • 包管理器支持: 支持 pnpm、npm 或 yarn
  • Docker 支持: 可选择生成 Dockerfile 和 docker-compose.yml
  • Git 集成: 自动初始化 git 仓库
  • Git Flow: 配置 Git Flow 工作流 (需要 git-flow 工具)
  • 🛡️ 错误边界: 全面的错误处理和兜底机制
  • 📊 错误监控: 内置错误监控和上报系统
  • 🔄 优雅关闭: 支持优雅关闭和资源清理

安装

pnpm add -g express-hale
# 或者
npx express-hale my-app
# 或者
pnpm create express-app my-app

使用方法

交互式模式

express-hale my-express-app

快速开始

pnpm create express-app my-app
cd my-app
pnpm install
pnpm run dev

CLI 选项

CLI 提供以下交互式配置选项:

  • 项目名称: Express 应用程序的名称
  • 编程语言: TypeScript 或 JavaScript
  • 数据库: 多选数据库 (MySQL、MongoDB、Redis)
  • 包管理器: pnpm、npm 或 yarn
  • 代码质量: ESLint 和 Prettier 配置
  • 测试框架: Jest 或 Mocha 配置
  • Docker: 可选容器化文件
  • Git: 初始化 git 仓库
  • Git Flow: 配置 Git Flow 工作流 (需要 git-flow 工具)

生成的项目结构

my-express-app/
├── src/
│   ├── config/          # 数据库配置文件
│   ├── controllers/     # 路由控制器
│   ├── middleware/      # 自定义中间件
│   ├── models/          # 数据库模型
│   ├── routes/          # API 路由
│   ├── services/        # 业务逻辑
│   ├── utils/           # 工具函数
│   └── index.ts         # 应用程序入口文件
├── tests/               # 测试文件
├── .env                 # 环境变量
├── .env.example         # 环境变量模板
├── .gitignore           # Git 忽略规则
├── .eslintrc.js         # ESLint 配置
├── .prettierrc          # Prettier 配置
├── jest.config.js       # Jest 配置
├── tsconfig.json        # TypeScript 配置
├── Dockerfile           # Docker 配置 (可选)
├── docker-compose.yml   # Docker Compose (可选)
├── GIT_FLOW.md          # Git Flow 工作流文档 (可选)
└── package.json         # 包配置文件

数据库配置

MySQL

// 使用环境变量自动生成连接配置
const pool = mysql.createPool({
  host: process.env.MYSQL_HOST,
  port: process.env.MYSQL_PORT,
  user: process.env.MYSQL_USER,
  password: process.env.MYSQL_PASSWORD,
  database: process.env.MYSQL_DATABASE,
});

MongoDB

// 带重连逻辑的 Mongoose 连接
mongoose.connect(process.env.MONGODB_URI);

Redis

// 带连接处理的 Redis 客户端
const client = createClient({
  host: process.env.REDIS_HOST,
  port: process.env.REDIS_PORT,
  password: process.env.REDIS_PASSWORD,
});

可用脚本

  • pnpm run dev - 启动开发服务器,支持热重载
  • pnpm run build - 构建 TypeScript 到 JavaScript (TS 项目)
  • pnpm start - 启动生产服务器
  • pnpm test - 运行测试套件
  • pnpm run lint - 使用 ESLint 检查代码
  • pnpm run format - 使用 Prettier 格式化代码

Git Flow 脚本 (如果启用)

  • pnpm run git:feature - 开始新功能分支
  • pnpm run git:feature-finish - 完成功能分支
  • pnpm run git:release - 开始发布分支
  • pnpm run git:release-finish - 完成发布分支
  • pnpm run git:hotfix - 开始热修复分支
  • pnpm run git:hotfix-finish - 完成热修复分支

环境变量

生成的 .env 文件包含:

# 服务器配置
PORT=3000
NODE_ENV=development

# 数据库配置 (如果选择了相应数据库)
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database

MONGODB_URI=mongodb://localhost:27017/your_database

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password

# JWT 密钥
JWT_SECRET=your_jwt_secret_key

Git Flow 工作流

如果选择了 Git Flow 选项,项目将包含 Git Flow 配置和相关脚本。

安装 Git Flow

macOS:

brew install git-flow-avh

Ubuntu/Debian:

sudo apt-get install git-flow

Windows:

# 使用 Git for Windows 或通过包管理器安装

使用说明

生成的项目会包含 GIT_FLOW.md 文件,详细说明了工作流程和命令使用方法。

开发

参与 Express Hale CLI 开发:

git clone https://github.com/your-username/express-hale.git
cd express-hale
pnpm install
pnpm run dev

许可证

MIT © Gaowenhan