config.default.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. config.static = {
  51. maxAge: 0,
  52. buffer: false,
  53. };
  54. // 分页相关
  55. config.pageSize = 15;
  56. // 中间件
  57. config.middleware = ['gzip', 'urlParse', 'sortFilter', 'autoLogger'];
  58. // session配置
  59. config.session = {
  60. key: 'ZHC_SESS',
  61. maxAge: 3600 * 1000 * 24, // 1小时
  62. httpOnly: true,
  63. encrypt: true,
  64. rolling: true, // 每次都更新session有效期
  65. };
  66. // session使用redis
  67. exports.sessionRedis = {
  68. name: 'session',
  69. };
  70. // 缓存时间
  71. config.cacheTime = 3600 * 24 * 31; // 31天 计量一期的时间,估计为1月
  72. // 安全性配置
  73. config.security = {
  74. csrf: {
  75. ignoreJSON: false, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
  76. },
  77. };
  78. // 发送短信相关
  79. config.sms = {
  80. // account: '710030',
  81. // password: 'w7pRhJ',
  82. // extno: '10690587',
  83. authKey: 'fb5ef483e44b9556512a9febef376051',
  84. };
  85. // geetest验证码key
  86. config.geetest = {
  87. id: '23c50f6711966f744c93a70167c8e0a4',
  88. key: '9b67989994f9def437ea68bb495f0162',
  89. };
  90. // 前端验证
  91. config.jsValidator = {
  92. client: {},
  93. app: true,
  94. };
  95. config.filePath = '/etc/calc/files';
  96. // 上传设置
  97. config.multipart = {
  98. whitelist: ['.json', '.txt',
  99. '.xls', '.xlsx',
  100. '.doc', '.docx',
  101. '.pdf',
  102. '.ppt', '.pptx',
  103. '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.cad', '.dwg',
  104. '.zip', '.rar', '.7z', ''],
  105. fileSize: '30mb',
  106. fields: '15',
  107. mode: 'file',
  108. };
  109. // 是否压缩替换前端js
  110. config.min = true;
  111. const file = appInfo.baseDir + '/config/version';
  112. config.version = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '1.0.5';
  113. // 压缩设置
  114. config.gzip = {
  115. threshold: 2048,
  116. // 下载的url要用正则忽略
  117. ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)|(\/download\/compresse-file)(\w*)/ig,
  118. };
  119. config.customLogger = {
  120. // 操作失败日志
  121. fail: {
  122. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'fail.log'),
  123. },
  124. // 以下为业务日志
  125. ledger: {
  126. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'ledger.log'),
  127. },
  128. stage: {
  129. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'stage.log'),
  130. },
  131. mixed: {
  132. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'mixed.log'),
  133. }
  134. };
  135. config.bodyParser = {
  136. jsonLimit: '10mb',
  137. formLimit: '10mb',
  138. };
  139. config.etag = {
  140. weak: false,
  141. };
  142. config.wechatAll = {
  143. appid: 'wx1c1cd8bae5836439',
  144. appsecret: 'a35104f156faf19ab7a3ae4f990a1dd4',
  145. token: 'smartcost3850888',
  146. encodingAESKey: 'yjTsgluXZnsx5At4XjtOgeIZzmPuuFqoa3tLe25WxtC',
  147. payment: {
  148. partnerKey: '',
  149. mchId: '',
  150. notifyUrl: '',
  151. pfx: '',
  152. },
  153. modules: {
  154. message: true, // enable or disable co-wechat
  155. api: true, // enable or disable co-wechat-api
  156. oauth: true, // enable or disable co-wechat-oauth
  157. payment: false, // enable or disable co-wechat-payment
  158. },
  159. };
  160. config.proxy = true;
  161. return config;
  162. };