config.default.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. 'use strict';
  2. const path = require('path');
  3. const fs = require('fs');
  4. module.exports = appInfo => {
  5. const config = {};
  6. // 数据库配置
  7. config.mysql = {
  8. client: {
  9. // host
  10. host: 'rm-wz9ae9t6qopwrday6.mysql.rds.aliyuncs.com',
  11. // 端口号
  12. port: '3306',
  13. // 用户名
  14. user: 'zh_calc',
  15. // 密码
  16. password: 'Zh@)!(3850Calc',
  17. // 数据库名
  18. database: 'calculation',
  19. },
  20. // 是否加载到 app 上,默认开启
  21. app: true,
  22. // 是否加载到 agent 上,默认关闭
  23. agent: false,
  24. };
  25. // 表名前缀
  26. config.tablePrefix = 'zh_';
  27. // redis设置
  28. config.redis = {
  29. client: {
  30. host: '127.0.0.1',
  31. port: '6379',
  32. password: 'zh@)!(3850sc',
  33. db: '0',
  34. },
  35. agent: true,
  36. version: '1.0.0',
  37. };
  38. // should change to your own
  39. config.keys = appInfo.name + '_1503910434503_882';
  40. // view相关
  41. config.view = {
  42. mapping: {
  43. '.ejs': 'ejs',
  44. },
  45. root: [
  46. path.join(appInfo.baseDir, 'app/view'),
  47. ].join(','),
  48. cache: false,
  49. };
  50. // 分页相关
  51. config.pageSize = 15;
  52. // 中间件
  53. config.middleware = ['gzip', 'urlParse', 'sortFilter', 'autoLogger'];
  54. // session配置
  55. config.session = {
  56. key: 'ZHC_SESS',
  57. maxAge: 3600 * 1000, // 1小时
  58. httpOnly: true,
  59. encrypt: true,
  60. };
  61. // session使用redis
  62. exports.sessionRedis = {
  63. name: 'session',
  64. };
  65. // 缓存时间
  66. config.cacheTime = 3600 * 24 * 31; // 31天 计量一期的时间,估计为1月
  67. // 安全性配置
  68. config.security = {
  69. csrf: {
  70. ignoreJSON: false, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
  71. },
  72. };
  73. // 发送短信相关
  74. config.sms = {
  75. // account: '710030',
  76. // password: 'w7pRhJ',
  77. // extno: '10690587',
  78. authKey: 'fb5ef483e44b9556512a9febef376051',
  79. };
  80. // geetest验证码key
  81. config.geetest = {
  82. id: '23c50f6711966f744c93a70167c8e0a4',
  83. key: '9b67989994f9def437ea68bb495f0162',
  84. };
  85. // 前端验证
  86. config.jsValidator = {
  87. client: {},
  88. app: true,
  89. };
  90. config.filePath = '/etc/calc/files';
  91. // 上传设置
  92. config.multipart = {
  93. whitelist: ['.json', '.txt',
  94. '.xls', '.xlsx',
  95. '.doc', '.docx',
  96. '.pdf',
  97. '.ppt', '.pptx',
  98. '.png', '.jpg', '.jpeg', '.gif', '.bmp',
  99. '.zip', '.rar', '.7z', ''],
  100. fileSize: '30mb',
  101. };
  102. // 是否压缩替换前端js
  103. config.min = true;
  104. const file = appInfo.baseDir + '/config/version';
  105. config.version = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '1.0.4';
  106. // 压缩设置
  107. config.gzip = {
  108. threshold: 2048,
  109. // 下载的url要用正则忽略
  110. ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)(\w*)/ig,
  111. };
  112. config.customLogger = {
  113. // 操作失败日志
  114. fail: {
  115. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'fail.log'),
  116. },
  117. // 以下为业务日志
  118. ledger: {
  119. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'ledger.log'),
  120. },
  121. stage: {
  122. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'stage.log'),
  123. },
  124. mixed: {
  125. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'mixed.log'),
  126. }
  127. };
  128. config.bodyParser = {
  129. jsonLimit: '10mb',
  130. formLimit: '10mb',
  131. };
  132. config.etag = {
  133. weak: false,
  134. };
  135. return config;
  136. };