1
This commit is contained in:
11
config/before_init_api.js
Normal file
11
config/before_init_api.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Framework.init 的 beforeInitApi:在 _setupRoutes 之前注册手动路由(规范见 .cursor/rules/node-core-framework.mdc)
|
||||
*/
|
||||
module.exports = async function beforeInitApi(framework) {
|
||||
const { buildProxyRoutes } = require("../api/controller_custom/proxy_api");
|
||||
const proxy_routes = buildProxyRoutes();
|
||||
const n = Object.keys(proxy_routes).length;
|
||||
framework.addRoutes("", proxy_routes);
|
||||
framework.addRoutes("/api", proxy_routes);
|
||||
console.log(`📡 已注册 ${n} 个转发接口(文档路径 + /api 前缀各一套)`);
|
||||
};
|
||||
@@ -3,8 +3,9 @@
|
||||
* 基于 node-core-framework 的配置
|
||||
*/
|
||||
|
||||
const baseConfig = require('./config.js');
|
||||
const customSchemas = require('./custom.schemas.js');
|
||||
const baseConfig = require("./config.js");
|
||||
const customSchemas = require("./custom.schemas.js");
|
||||
const beforeInitApi = require("./before_init_api");
|
||||
|
||||
module.exports = {
|
||||
// ===== 必需配置 =====
|
||||
@@ -119,6 +120,9 @@ module.exports = {
|
||||
|
||||
|
||||
// 自定义 Swagger Schemas
|
||||
customSchemas: customSchemas
|
||||
customSchemas: customSchemas,
|
||||
|
||||
// 路由流水线早期回调:注册转发等 addRoutes(勿在 init 之后散落注册)
|
||||
beforeInitApi,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user