feat: 初始化多个小程序和前端项目
- 新建多个小程序的 app.js、app.json 和 app.wxss 文件 - 新建多个前端项目的 App.vue 文件 - 添加 .gitignore 文件和后端 API 的 .env.example 文件
This commit is contained in:
25
backend/api/.env.example
Normal file
25
backend/api/.env.example
Normal file
@@ -0,0 +1,25 @@
|
||||
# 服务器配置
|
||||
PORT=8000
|
||||
|
||||
# 数据库配置
|
||||
DB_HOST=localhost
|
||||
DB_USER=root
|
||||
DB_PASSWORD=password
|
||||
DB_NAME=xlxumu
|
||||
DB_PORT=3306
|
||||
|
||||
# JWT配置
|
||||
JWT_SECRET=your_jwt_secret_key_here
|
||||
JWT_EXPIRES_IN=24h
|
||||
|
||||
# 腾讯云存储配置
|
||||
TENCENT_CLOUD_SECRET_ID=your_secret_id
|
||||
TENCENT_CLOUD_SECRET_KEY=your_secret_key
|
||||
TENCENT_CLOUD_BUCKET=your_bucket_name
|
||||
TENCENT_CLOUD_REGION=your_region
|
||||
|
||||
# 日志配置
|
||||
LOG_LEVEL=info
|
||||
|
||||
# 其他配置
|
||||
NODE_ENV=development
|
||||
30
backend/api/package.json
Normal file
30
backend/api/package.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "xlxumu-api",
|
||||
"version": "1.0.0",
|
||||
"description": "锡林郭勒盟安格斯牛数字化管理平台API服务",
|
||||
"author": "xlxumu team",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"dev": "nodemon server.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.18.0",
|
||||
"cors": "^2.8.5",
|
||||
"helmet": "^6.0.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"mysql2": "^3.0.0",
|
||||
"sequelize": "^6.0.0",
|
||||
"joi": "^17.0.0",
|
||||
"winston": "^3.8.0",
|
||||
"express-rate-limit": "^6.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.0",
|
||||
"jest": "^29.0.0",
|
||||
"supertest": "^6.3.0"
|
||||
}
|
||||
}
|
||||
48
backend/api/server.js
Normal file
48
backend/api/server.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const helmet = require('helmet');
|
||||
const dotenv = require('dotenv');
|
||||
const rateLimit = require('express-rate-limit');
|
||||
|
||||
// 加载环境变量
|
||||
dotenv.config();
|
||||
|
||||
// 创建Express应用
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 8000;
|
||||
|
||||
// 中间件
|
||||
app.use(helmet()); // 安全头部
|
||||
app.use(cors()); // 跨域支持
|
||||
app.use(express.json({ limit: '10mb' })); // JSON解析
|
||||
app.use(express.urlencoded({ extended: true, limit: '10mb' })); // URL编码解析
|
||||
|
||||
// 速率限制
|
||||
const limiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15分钟
|
||||
max: 100, // 限制每个IP 15分钟内最多100个请求
|
||||
message: '请求过于频繁,请稍后再试'
|
||||
});
|
||||
app.use(limiter);
|
||||
|
||||
// 基础路由
|
||||
app.get('/', (req, res) => {
|
||||
res.json({
|
||||
message: '欢迎使用锡林郭勒盟安格斯牛数字化管理平台API服务',
|
||||
version: '1.0.0'
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/health', (req, res) => {
|
||||
res.json({
|
||||
status: 'OK',
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
});
|
||||
|
||||
// 启动服务器
|
||||
app.listen(PORT, () => {
|
||||
console.log(`API服务器正在端口 ${PORT} 上运行`);
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
Reference in New Issue
Block a user