config.default.js 4.6 KB

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