Files
wechatWeb/config/framework.config.js
张成 7d0a921805 1
2026-03-25 19:01:28 +08:00

125 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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:9099'; // 开发环境
}
})(),
// 日志路径
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
};