update server/routers/back-new/app.js
This commit is contained in:
@@ -1,24 +1,22 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const cors = require('cors');
|
|
||||||
const featuresConfig = require('./features.config');
|
const featuresConfig = require('./features.config');
|
||||||
const imageRoutes = require('./features/image/image.routes');
|
const imageRoutes = require('./features/image/image.routes');
|
||||||
|
|
||||||
const app = express();
|
const router = express.Router();
|
||||||
app.use(cors());
|
|
||||||
app.use(express.json());
|
|
||||||
|
|
||||||
|
// 动态加载路由
|
||||||
if (featuresConfig.auth) {
|
if (featuresConfig.auth) {
|
||||||
app.use('/api/auth', require('./features/auth/auth.routes'));
|
router.use('/auth', require('./features/auth/auth.routes'));
|
||||||
}
|
}
|
||||||
if (featuresConfig.user) {
|
if (featuresConfig.user) {
|
||||||
app.use('/api/user', require('./features/user/user.routes'));
|
router.use('/user', require('./features/user/user.routes'));
|
||||||
}
|
}
|
||||||
if (featuresConfig.image) {
|
if (featuresConfig.image) {
|
||||||
app.use('/gigachat', imageRoutes);
|
router.use('/image', imageRoutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/api/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
res.json({ message: 'API root' });
|
res.json({ message: 'API root' });
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = router;
|
||||||
Reference in New Issue
Block a user