upload files

This commit is contained in:
xingzhe.ru
2025-06-29 22:31:00 +00:00
parent 80b9d9c8c8
commit b1a9ee1403
7 changed files with 1098 additions and 0 deletions

2
server/routers/back-new/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules/
.env

View File

@@ -0,0 +1,21 @@
# back-new
非Python实现的后端Node.js + Express
## 启动方法
1. 安装依赖:
```bash
npm install
```
2. 启动服务:
```bash
npm start
```
默认端口:`3002`
## 支持接口
- POST `/api/auth/login` 用户登录
- POST `/api/auth/register` 用户注册
- GET `/gigachat/prompt?prompt=xxx` 生成图片(返回模拟图片链接)

View File

@@ -0,0 +1,24 @@
const express = require('express');
const cors = require('cors');
const featuresConfig = require('./features.config');
const imageRoutes = require('./features/image/image.routes');
const app = express();
app.use(cors());
app.use(express.json());
if (featuresConfig.auth) {
app.use('/api/auth', require('./features/auth/auth.routes'));
}
if (featuresConfig.user) {
app.use('/api/user', require('./features/user/user.routes'));
}
if (featuresConfig.image) {
app.use('/gigachat', imageRoutes);
}
app.get('/api/', (req, res) => {
res.json({ message: 'API root' });
});
module.exports = app;

View File

@@ -0,0 +1,5 @@
module.exports = {
auth: true,
user: true,
image: true, // 关闭为 false
};

1024
server/routers/back-new/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
{
"name": "back-new",
"version": "1.0.0",
"description": "非Python实现的后端兼容前端接口",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"axios": "^1.10.0",
"cors": "^2.8.5",
"dotenv": "^17.0.0",
"express": "^4.21.2",
"qs": "^6.14.0",
"uuid": "^11.1.0"
}
}

View File

@@ -0,0 +1,5 @@
const app = require('./app');
const PORT = process.env.PORT || 3002;
app.listen(PORT, () => {
console.log(`Mock backend running on http://localhost:${PORT}`);
});