yuheng/README.md
2025-03-18 18:17:37 +08:00

58 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# RBAC 权限管理系统
基于 Fastify 的 Node.js 角色访问控制RBAC系统提供灵活的权限管理能力。
## 主要特性
- 🛡️ 基于 JWT 的身份认证
- 🔑 角色-权限层级管理
- 🚦 请求权限验证中间件
- 📦 支持 PostgreSQL/MySQL 数据库
- 📝 审计日志记录
## 快速开始
### 前置要求
- Node.js v18+
- 数据库PostgreSQL/MySQL
- Redis用于会话管理
### 安装步骤
```bash
# 克隆仓库
git clone https://github.com/your-repo.git
cd rbac-system
# 安装依赖
npm install
# 配置环境变量(复制示例文件)
cp .env.example .env
# 数据库迁移
npx prisma migrate dev
# 启动服务
npm run dev
## 项目结构
```bash
├── src/
│ ├── routes/ # API 路由
│ │ ├── index.js # 路由入口
│ │ ├── user.js # 用户相关路由
│ ├── plugins/ # Fastify 插件
│ │ ├── db.js # 数据库连接
│ ├── services/ # 业务逻辑层
│ │ ├── userService.js # 用户服务
│ ├── utils/ # 工具类
│ │ ├── logger.js # 日志工具
│ ├── app.js # 应用入口
├── test/ # 测试用例
│ ├── routes/
│ │ ├── user.test.js # 用户路由测试
│ ├── utils/
│ │ ├── logger.test.js # 日志工具测试
├── config/ # 配置文件
│ ├── default.js # 通用配置
├── package.json # 依赖管理
```