config.default.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. cookieName: 'csrfToken_j', // csrf token's cookie name
  77. sessionName: 'csrfToken_j', // csrf token's session name
  78. headerName: 'x-csrf-token_j', // request csrf token's name in header
  79. bodyName: '_csrf_j', // request csrf token's name in body
  80. queryName: '_csrf_j', // request csrf token's name in query
  81. },
  82. };
  83. // 发送短信相关
  84. config.sms = {
  85. // account: '710030',
  86. // password: 'w7pRhJ',
  87. // extno: '10690587',
  88. authKey: 'fb5ef483e44b9556512a9febef376051',
  89. };
  90. // geetest验证码key
  91. config.geetest = {
  92. id: '23c50f6711966f744c93a70167c8e0a4',
  93. key: '9b67989994f9def437ea68bb495f0162',
  94. };
  95. // 前端验证
  96. config.jsValidator = {
  97. client: {},
  98. app: true,
  99. };
  100. config.filePath = '/etc/calc/files';
  101. // 上传设置
  102. config.multipart = {
  103. whitelist: ['.json', '.txt',
  104. '.xls', '.xlsx',
  105. '.doc', '.docx',
  106. '.pdf',
  107. '.ppt', '.pptx',
  108. '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.cad', '.dwg',
  109. '.zip', '.rar', '.7z', ''],
  110. fileSize: '30mb',
  111. fields: '15',
  112. };
  113. // 是否压缩替换前端js
  114. config.min = true;
  115. const file = path.join(__dirname, 'version');
  116. console.log(file);
  117. if (fs.existsSync(file)) {
  118. const versionStr = fs.readFileSync(file, 'utf8');
  119. config.version = versionStr.split('\n')[0];
  120. } else {
  121. config.version = '1.0.5';
  122. }
  123. // 压缩设置
  124. config.gzip = {
  125. threshold: 2048,
  126. // 下载的url要用正则忽略
  127. ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)|(\/download\/compresse-file)(\w*)/ig,
  128. };
  129. config.customLogger = {
  130. // 操作失败日志
  131. fail: {
  132. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'fail.log'),
  133. },
  134. // 以下为业务日志
  135. ledger: {
  136. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'ledger.log'),
  137. },
  138. stage: {
  139. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'stage.log'),
  140. },
  141. mixed: {
  142. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'mixed.log'),
  143. }
  144. };
  145. config.bodyParser = {
  146. jsonLimit: '10mb',
  147. formLimit: '10mb',
  148. };
  149. config.etag = {
  150. weak: false,
  151. };
  152. config.wechatAll = {
  153. appid: 'wx1c1cd8bae5836439',
  154. appsecret: 'a35104f156faf19ab7a3ae4f990a1dd4',
  155. token: 'smartcost3850888',
  156. encodingAESKey: 'yjTsgluXZnsx5At4XjtOgeIZzmPuuFqoa3tLe25WxtC',
  157. payment: {
  158. partnerKey: '',
  159. mchId: '',
  160. notifyUrl: '',
  161. pfx: '',
  162. },
  163. modules: {
  164. message: true, // enable or disable co-wechat
  165. api: true, // enable or disable co-wechat-api
  166. oauth: true, // enable or disable co-wechat-oauth
  167. payment: false, // enable or disable co-wechat-payment
  168. },
  169. };
  170. // wx扫码登录
  171. config.wxCode = {
  172. appid: 'wx5320cd30cecdbd68',
  173. appsecret: 'ca7c0dbd9e94dc3b1c3b0e73865743f4',
  174. };
  175. config.proxy = true;
  176. return config;
  177. };