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

bunel

v0.1.3

Published

CLI tool for Elysia framework to generate modules and scaffold projects

Readme

Bunel CLI

Bunel 是一个基于 Bun 和 Elysia 框架的命令行工具,用于快速生成模块和搭建项目脚手架。它提供了便捷的命令来初始化项目和生成符合最佳实践的模块代码。

特性

  • 🚀 快速项目初始化:支持多种模板快速搭建项目基础结构
  • 📦 模块生成:自动生成包含控制器、服务、DTO 的完整模块
  • ⚡ 基于 Bun:利用 Bun 的高性能特性
  • 🔧 生产就绪:提供生产级模板,包含数据库集成、中间件等功能
  • 🛠 可扩展:易于定制和扩展模板

技术栈

  • Bun - JavaScript 运行时
  • Elysia - TypeScript Web 框架
  • TypeScript - 类型安全
  • Prisma - 数据库工具包 (在 prod 模板中)
  • Redis - 内存数据存储 (在 prod 模板中)

安装

你可以通过以下方式之一安装 Bunel CLI:

全局安装

bun install -g bunel

注意:安装后可能会看到类似以下的提示:

warn: To run "bunel", add the global bin folder to $PATH:

如果遇到此提示,需要将 npm 全局 bin 目录添加到 PATH 环境变量中:

  • Windows: 将 C:\Users\<用户名>\AppData\Roaming\npm 添加到系统 PATH
  • macOS/Linux: 将 npm 全局 bin 目录(如 ~/.npm-global/bin/usr/local/bin)添加到 shell 配置文件中

使用 npx (无需安装)

bunx bunel

这种方式无需全局安装,也不会遇到环境变量问题。

使用方法

初始化项目

使用 init 命令可以快速创建一个新的 Elysia 项目:

bunel init my-project

你也可以指定模板类型 (默认为 base):

bunel init my-project -t prod

可用的模板类型:

  • base - 基础模板,包含基本的 Elysia 项目结构
  • prod - 生产模板,包含数据库集成、认证、日志等生产级功能

生成组件

使用 generate 命令可以生成各种类型的组件:

生成资源 (Resource)

生成包含 CRUD 操作的完整资源(控制器、服务、DTO):

bunel generate resource user

你也可以使用别名 res

bunel g res user

指定生成路径(默认为 src/modules):

bunel g res post -p src/api

生成 Prisma 配置

设置 Prisma ORM 及其配置文件:

bunel generate prisma

生成定时任务

创建一个新的定时任务:

bunel generate jobs notification-cleaner

使用别名:

bunel g job cache-updater

生成 Redis 集成

设置 Redis 集成及其插件:

bunel generate redis

生成 WebSocket 服务

创建一个新的 WebSocket 服务:

bunel generate ws chat

使用别名:

bunel g ws notification

生成 SSE 服务

创建一个新的 Server-Sent Events 服务:

bunel generate sse event-stream

模板详情

Base 模板

基础模板包含:

  • 基本的 Elysia 应用结构
  • TypeScript 配置
  • 简单的工具函数
  • 标准的项目组织结构

Prod 模板

生产模板包含:

  • 数据库集成 (Prisma)
  • 环境变量管理
  • 认证和授权中间件
  • 日志系统
  • 错误处理中间件
  • Redis 集成
  • WebSocket 支持
  • 文件上传插件
  • OpenAPI 文档
  • 定时任务

开发脚本

生成的项目包含以下有用的脚本:

  • bun run dev - 启动开发服务器(带热重载)
  • bun run start - 启动生产服务器
  • bun run build - 构建生产版本
  • bun run preview - 预览构建版本
  • bun run prisma:generate - 生成 Prisma 客户端
  • bun run prisma:migrate - 运行数据库迁移
  • bun run prisma:studio - 启动 Prisma Studio
  • bun run format - 格式化代码
  • bun run lint - 代码检查
  • bun run validate - 格式化并检查代码

示例

创建新项目

# 创建基础项目
bunel init my-app

# 创建生产级项目
bunel init my-api -t prod

添加模块和组件

# 进入项目目录
cd my-api

# 生成用户资源
bunel generate resource user

# 生成文章资源
bunel generate resource post

# 生成定时任务
bunel generate jobs log-cleaner

# 生成 WebSocket 服务
bunel generate ws chat

# 生成 SSE 服务
bunel generate sse events

这将在相应目录下创建相应的组件,包含完整的功能实现。

目录结构

基础模板的目录结构:

my-project/
├── src/
│   ├── modules/
│   │   └── index.ts
│   ├── utils/
│   │   └── resFormat.ts
│   └── index.ts
├── package.json
├── tsconfig.json
└── README.md

生产模板的目录结构更复杂,包含了数据库、中间件、插件等功能模块。

贡献

欢迎提交 Issue 和 Pull Request 来改进此工具!

许可证

MIT License