JY API 服务

📄 README.md 🕒 8/10/2025, 6:55:39 PM 📏 4KB

JY API 服务

一个基于 Node.js 和 Express.js 的 RESTful API 服务框架。

功能特性

项目结构

jy_api/
├── app.js                 # 应用入口文件
├── package.json           # 项目配置
├── .env.example          # 环境变量示例
├── .gitignore            # Git忽略文件
├── controllers/          # 控制器
│   ├── authController.js
│   └── userController.js
├── routes/               # 路由
│   ├── auth.js
│   └── users.js
├── middleware/           # 中间件
│   └── auth.js
├── utils/                # 工具函数
│   ├── response.js
│   └── validator.js
└── config/               # 配置文件
    └── database.js

快速开始

1. 安装依赖

npm install

2. 环境配置

复制 .env.example.env 并配置相应的环境变量:

cp .env.example .env

3. 启动开发服务器

# 开发模式(自动重启)
npm run dev

# 生产模式
npm start

服务器将在 https://jy-api.fyshark.com 启动

API 接口

基础接口

用户管理

身份认证

草稿和素材管理

📖 完整API文档

请求示例

创建用户

curl -X POST https://jy-api.fyshark.com/api/users \
  -H "Content-Type: application/json" \
  -d '{
    "name": "测试用户",
    "email": "test@example.com",
    "age": 25
  }'

用户登录

curl -X POST https://jy-api.fyshark.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "admin@example.com",
    "password": "123456"
  }'

响应格式

所有API响应都遵循统一格式:

{
  "status": "success|error",
  "message": "响应消息",
  "data": {},
  "timestamp": "2023-12-01T10:00:00.000Z"
}

📋 开发规范

本项目遵循严格的开发规范,确保代码质量和文档完整性:

🔥 核心规则

每个新建的API接口都必须提供对应的使用说明文档(Markdown格式)

📖 文档规范

🛠️ 开发工具

创建API文档

# 创建新的API文档
./scripts/create-api-doc.sh <接口名称> [HTTP方法] [路径]

# 示例
./scripts/create-api-doc.sh USER_LOGIN POST /api/auth/login
./scripts/create-api-doc.sh GET_USER_INFO GET /api/users/:id

检查文档规范

# 检查所有API文档的完整性
./scripts/check-api-docs.sh

📚 相关文档

🔍 贡献流程

  1. Fork 这个仓库
  2. 创建功能分支 (git checkout -b feature/AmazingFeature)
  3. 📖 为新接口创建API文档 (./scripts/create-api-doc.sh YourAPI)
  4. 提交修改 (git commit -m 'Add some AmazingFeature')
  5. 🔍 检查文档规范 (./scripts/check-api-docs.sh)
  6. 推送到分支 (git push origin feature/AmazingFeature)
  7. 打开拉取请求

⚠️ 注意: 没有对应API文档的接口将无法通过代码审查

开发计划

许可证

MIT