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

@massong/create-template-node

v1.4.3

Published

A CLI tool to create Node.js projects with Koa2 + MySQL template

Readme

@massong/create-template-node

一个用于快速创建 Node.js + Koa2 + MySQL 项目模板的脚手架工具。

🚀 快速开始

方式一:npm init(推荐)

npm init @massong/template-node@latest my-project

方式二:npx

npx @massong/create-template-node my-project

方式三:全局安装

# 全局安装
npm install -g @massong/create-template-node

# 使用
create-template-node my-project
# 或者
template-node my-project

📋 功能特性

  • 🎯 交互式配置 - 通过命令行交互式配置项目信息
  • 🗄️ 数据库配置 - 支持 MySQL 数据库连接配置
  • 📦 自动安装依赖 - 可选择自动安装 npm 依赖
  • 🔧 环境配置 - 自动生成 .env 配置文件
  • 📚 完整模板 - 包含完整的 Koa2 + MySQL 项目结构
  • 🎨 代码规范 - 内置 ESLint 代码规范检查

🛠️ 生成的项目结构

my-project/
├── app.js                 # 应用入口文件
├── package.json           # 项目配置文件
├── .env                   # 环境变量配置
├── .env.example          # 环境变量示例
├── .gitignore            # Git 忽略文件
├── README.md             # 项目说明文档
├── controllers/          # 控制器层
│   └── authController.js # 认证控制器
├── services/             # 服务层(业务逻辑)
│   └── authService.js    # 认证服务
├── middlewares/          # 中间件
│   ├── auth.js           # 认证中间件
│   ├── errorHandler.js   # 错误处理中间件
│   ├── mysql.js          # 数据库连接池
│   ├── response.js       # 响应格式化中间件
│   └── validator.js      # 数据验证中间件
├── routes/               # 路由层
│   ├── index.js          # 主路由
│   └── authRoutes.js     # 认证路由
└── sql/                  # 数据库脚本
    └── init.sql          # 数据库初始化脚本

🎯 使用流程

  1. 运行创建命令

    npm init template-node@latest my-project
  2. 按提示配置项目

    • 项目名称
    • 项目描述
    • 作者名称
    • 服务端口
    • 数据库配置(可选)
    • 是否自动安装依赖
  3. 进入项目目录

    cd my-project
  4. 启动开发服务器

    npm run dev

📝 配置选项

项目基本信息

  • 项目名称: 符合 npm 包命名规范的项目名称
  • 项目描述: 项目的简短描述
  • 作者名称: 项目作者信息
  • 服务端口: Web 服务器监听端口(默认 8081)

数据库配置

  • 数据库主机: MySQL 服务器地址(默认 localhost)
  • 数据库端口: MySQL 服务器端口(默认 3306)
  • 数据库用户名: 数据库连接用户名(默认 root)
  • 数据库密码: 数据库连接密码
  • 数据库名称: 数据库名称(默认使用项目名称)

🔧 生成的项目特性

  • Koa2 框架 - 轻量级、高性能的 Node.js Web 框架
  • MVC 架构 - 清晰的代码组织结构
  • RESTful API - 标准的 REST API 设计
  • 用户认证 - JWT Token 认证机制
  • MySQL 8 - 支持 MySQL 8 数据库
  • 连接池 - 数据库连接池管理
  • 事务支持 - 数据库事务处理
  • 参数验证 - 使用 Joi 进行请求参数验证
  • 错误处理 - 统一的错误处理机制
  • 响应格式化 - 标准化的 API 响应格式
  • CORS 支持 - 跨域资源共享
  • 环境配置 - 支持多环境配置
  • 模块规范 - 统一的导出导入规范

🚀 项目启动

生成项目后,可以使用以下命令启动:

# 开发模式(支持热重载)
npm run dev

# 生产模式
npm start

📚 API 文档

生成的项目包含完整的 API 文档,启动服务后访问:

  • 健康检查: GET /api/v1/health
  • 认证健康检查: GET /api/v1/auth/health
  • 用户登录: POST /api/v1/auth/login
  • 获取用户信息: GET /api/v1/auth/me
  • 修改密码: PUT /api/v1/auth/change-password

🤝 贡献

欢迎提交 Issue 和 Pull Request 来改进这个脚手架工具。

📄 许可证

本项目采用 MIT 许可证。

🙏 致谢


Happy Coding! 🎉