config.default.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. };
  108. // 是否压缩替换前端js
  109. config.min = true;
  110. const file = appInfo.baseDir + '/config/version';
  111. config.version = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '1.0.5';
  112. // 压缩设置
  113. config.gzip = {
  114. threshold: 2048,
  115. // 下载的url要用正则忽略
  116. ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)(\w*)/ig,
  117. };
  118. config.customLogger = {
  119. // 操作失败日志
  120. fail: {
  121. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'fail.log'),
  122. },
  123. // 以下为业务日志
  124. ledger: {
  125. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'ledger.log'),
  126. },
  127. stage: {
  128. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'stage.log'),
  129. },
  130. mixed: {
  131. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'mixed.log'),
  132. }
  133. };
  134. config.bodyParser = {
  135. jsonLimit: '10mb',
  136. formLimit: '10mb',
  137. };
  138. config.etag = {
  139. weak: false,
  140. };
  141. config.wechatAll = {
  142. appid: 'wx1c1cd8bae5836439',
  143. appsecret: 'a35104f156faf19ab7a3ae4f990a1dd4',
  144. token: 'smartcost3850888',
  145. encodingAESKey: 'yjTsgluXZnsx5At4XjtOgeIZzmPuuFqoa3tLe25WxtC',
  146. payment: {
  147. partnerKey: '',
  148. mchId: '',
  149. notifyUrl: '',
  150. pfx: '',
  151. },
  152. modules: {
  153. message: true, // enable or disable co-wechat
  154. api: true, // enable or disable co-wechat-api
  155. oauth: true, // enable or disable co-wechat-oauth
  156. payment: false, // enable or disable co-wechat-payment
  157. },
  158. };
  159. return config;
  160. };