This commit is contained in:
张成
2026-03-24 16:07:02 +08:00
commit aa8eaa6ccd
121 changed files with 34042 additions and 0 deletions

124
config/framework.config.js Normal file
View File

@@ -0,0 +1,124 @@
/**
* Framework 配置文件
* 基于 node-core-framework 的配置
*/
const baseConfig = require('./config.js');
const customSchemas = require('./custom.schemas.js');
module.exports = {
// ===== 必需配置 =====
env: process.env.NODE_ENV || 'development',
"project_key": "app_template",
// 数据库配置(必需)
db: {
username: baseConfig.db.username,
password: baseConfig.db.password,
database: baseConfig.db.database,
host: baseConfig.db.host,
port: baseConfig.db.port || 3306,
dialect: baseConfig.db.dialect || 'mysql',
timezone: '+08:00',
pool: {
max: 100, // 15 × 4 = 60 连接
min: 2,
acquire: 60000,
idle: 10000
},
slowSQLThreshold: 1000,
logging: (() => {
// 启用SQL监控
return (sql, timing) => {
// 调用监控函数
// 开发环境仍然输出日志
if (process.env.NODE_ENV === 'development') {
console.log(`[SQL] ${timing}ms - ${typeof sql === 'string' ? sql : (sql.sql || JSON.stringify(sql))}`);
}
};
})()
},
// API 路径配置(必需)
apiPaths: [
{
path: './api/controller_front',
prefix: '/api',
authType: 'applet'
},
{
path: './api/controller_admin',
prefix: '/admin_api',
authType: 'admin'
}
],
"fileConifg": {
"vue": {
"api": "../../admin/src/api/",
"view": "../../admin/src/view/"
},
"node": {
"controller": "../controller_admin/",
"model": "../model/"
}
},
// API文档配置
swagger: {
title: '后端 API',
version: '1.0.0',
description: '模板项目 API 文档',
contact: {
name: '开发团队',
email: 'dev@example.com'
}
},
// ===== 建议配置 =====
// 基础 URL根据环境区分
baseUrl: (() => {
const env = process.env.NODE_ENV || 'production';
switch (env) {
case 'production':
return 'https://example.com'; // 生产环境(请按实际域名修改)
case 'development':
default:
return 'http://localhost:9098'; // 开发环境
}
})(),
// 日志路径
logPath: './logs',
// 白名单 URL不需要认证的接口
allowUrls: baseConfig.allowUrls,
// 授权文件路径(可选,如果不需要授权验证可以设置为 null
// 授权验证配置
license: {
licensePath: require('path').join(__dirname, '_license', 'license.lic')
},
// Redis 配置
redis: baseConfig.redis || null,
// 模型路径
modelPaths: './api/model',
// ===== 业务配置(从原 config.js 继承)=====
// 端口配置
port: baseConfig.port,
// 自定义 Swagger Schemas
customSchemas: customSchemas
};