config.default.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. // 设置mysql连接字符集
  20. charset: 'utf8mb4',
  21. },
  22. // 是否加载到 app 上,默认开启
  23. app: true,
  24. // 是否加载到 agent 上,默认关闭
  25. agent: false,
  26. };
  27. // 表名前缀
  28. config.tablePrefix = 'zh_';
  29. // redis设置
  30. config.redis = {
  31. client: {
  32. host: '127.0.0.1',
  33. port: '6379',
  34. password: 'zh@)!(3850sc',
  35. db: '0',
  36. },
  37. agent: true,
  38. version: '1.0.0',
  39. };
  40. // should change to your own
  41. config.keys = 'calculation_1503910434503_882';
  42. // view相关
  43. config.view = {
  44. mapping: {
  45. '.ejs': 'ejs',
  46. },
  47. root: [
  48. path.join(appInfo.baseDir, 'app/view'),
  49. ].join(','),
  50. cache: false,
  51. };
  52. config.static = {
  53. maxAge: 0,
  54. buffer: false,
  55. };
  56. // 分页相关
  57. config.pageSize = 15;
  58. // 中间件
  59. config.middleware = ['gzip', 'urlParse', 'sortFilter', 'autoLogger', 'autoFinishLogger'];
  60. // session配置
  61. config.session = {
  62. key: 'ZHC_SESS',
  63. maxAge: 3600 * 1000 * 24, // 1小时
  64. httpOnly: true,
  65. encrypt: true,
  66. rolling: true, // 每次都更新session有效期
  67. };
  68. // session使用redis
  69. exports.sessionRedis = {
  70. name: 'session',
  71. };
  72. // 缓存时间
  73. config.cacheTime = 3600 * 24 * 31; // 31天 计量一期的时间,估计为1月
  74. // 安全性配置
  75. config.security = {
  76. csrf: {
  77. ignoreJSON: false, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
  78. ignore: '/wx', // 不进行安全校验,微信调用
  79. cookieName: 'csrfToken_j', // csrf token's cookie name
  80. sessionName: 'csrfToken_j', // csrf token's session name
  81. bodyName: '_csrf_j', // request csrf token's name in body
  82. queryName: '_csrf_j', // request csrf token's name in query
  83. cookie: {
  84. httpOnly: true,
  85. // secure: true, // 如果站点使用了HTTPS,可以开启此选项
  86. }
  87. },
  88. };
  89. // 发送短信相关
  90. config.sms = {
  91. // account: '710030',
  92. // password: 'w7pRhJ',
  93. // extno: '10690587',
  94. authKey: 'fb5ef483e44b9556512a9febef376051',
  95. };
  96. // geetest验证码key
  97. config.geetest = {
  98. id: '23c50f6711966f744c93a70167c8e0a4',
  99. key: '9b67989994f9def437ea68bb495f0162',
  100. };
  101. // 前端验证
  102. config.jsValidator = {
  103. client: {},
  104. app: true,
  105. };
  106. config.filePath = '/etc/calc/files';
  107. // 上传设置
  108. config.multipart = {
  109. whitelist: ['.cpd', '.yup', '.ybpx',
  110. '.json', '.txt',
  111. '.xls', '.xlsx',
  112. '.doc', '.docx',
  113. '.pdf',
  114. '.ppt', '.pptx',
  115. '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.cad', '.dwg',
  116. '.zip', '.rar', '.7z', ''],
  117. fileSize: '100mb',
  118. fields: '15',
  119. };
  120. // 是否压缩替换前端js
  121. config.min = true;
  122. const file = path.join(__dirname, 'version');
  123. if (fs.existsSync(file)) {
  124. const versionStr = fs.readFileSync(file, 'utf8');
  125. config.version = versionStr.split('\n')[0];
  126. } else {
  127. config.version = '1.0.5';
  128. }
  129. // 压缩设置
  130. config.gzip = {
  131. threshold: 2048,
  132. // 下载的url要用正则忽略
  133. ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)|(\/download\/compresse-file)|(\/compresse\/file)|(\/im-file\/download)(\w*)/ig,
  134. };
  135. config.customLogger = {
  136. // 操作失败日志
  137. fail: {
  138. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'fail.log'),
  139. },
  140. // 以下为业务日志
  141. ledger: {
  142. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'ledger.log'),
  143. },
  144. stage: {
  145. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'stage.log'),
  146. },
  147. mixed: {
  148. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'mixed.log'),
  149. },
  150. finish: {
  151. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'finish.log'),
  152. },
  153. warning: {
  154. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'warning.log'),
  155. },
  156. out: {
  157. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'out.log'),
  158. }
  159. };
  160. config.bodyParser = {
  161. jsonLimit: '10mb',
  162. formLimit: '10mb',
  163. queryString: {
  164. arrayLimit: 100,
  165. depth: 5,
  166. parameterLimit: 1000,
  167. },
  168. enableTypes: ['json', 'form', 'text'],
  169. extendTypes: {
  170. text: ['text/xml', 'application/xml'],
  171. },
  172. };
  173. config.etag = {
  174. weak: false,
  175. };
  176. config.wechatAll = {
  177. appid: 'wx1c1cd8bae5836439',
  178. appsecret: 'a35104f156faf19ab7a3ae4f990a1dd4',
  179. token: 'smartcost3850888',
  180. encodingAESKey: 'yjTsgluXZnsx5At4XjtOgeIZzmPuuFqoa3tLe25WxtC',
  181. payment: {
  182. partnerKey: '',
  183. mchId: '',
  184. notifyUrl: '',
  185. pfx: '',
  186. },
  187. modules: {
  188. message: true, // enable or disable co-wechat
  189. api: true, // enable or disable co-wechat-api
  190. oauth: true, // enable or disable co-wechat-oauth
  191. payment: false, // enable or disable co-wechat-payment
  192. },
  193. };
  194. // wx扫码登录
  195. config.wxCode = {
  196. appid: 'wx3d5394b238a3bc9a',
  197. appsecret: '457d64c55f48f57cd22eca47e53d15cb',
  198. };
  199. // 企业微信代开发模板信息
  200. config.qywx = {
  201. suiteID: 'dk1f00b68c19d825ba',
  202. suiteSecret: 'xYP1oRNDa5BcdNXxJXgZjvWpwuECWki5RLdA-xhdeRo',
  203. token: 'NRPyXeKObE3Nesc',
  204. encodingAESKey: 'a6zuXvcHQlgdyY8465AbVpMpSKF0HMf0aMMxRthuOiq',
  205. };
  206. config.proxy = true;
  207. config.hisOssPath = 'prod/';
  208. config.stashOssPath = 'stash/prod/';
  209. config.oss = {
  210. clients: {
  211. signPdf: {
  212. bucket: 'measure-sign-pdf',
  213. },
  214. fujian: {
  215. bucket: 'jiliang-saas',
  216. },
  217. his: {
  218. bucket: 'jiliang-his',
  219. }
  220. },
  221. default: {
  222. accessKeyId: 'LTAIALMjBHOs9PLA',
  223. accessKeySecret: 'HSnULQs87wAJhcziAdyRv3GZ4EYctc',
  224. endpoint: 'oss-cn-shenzhen-internal.aliyuncs.com',
  225. timeout: '60s',
  226. },
  227. };
  228. config.fujianOssPath = 'https://jiliang-saas-oss-cdn.smartcost.com.cn/';
  229. config.fujianOssFolder = '';
  230. config.syncUrl = 'https://jl-sync.smartcost.com.cn/';
  231. // 项目管理跳转路径
  232. config.managementPath = 'https://pm.smartcost.com.cn';
  233. config.managementProxyPath = 'https://pm.smartcost.com.cn';
  234. config.url3f = '/3f';
  235. config.table_depart = {
  236. heavy: 100,
  237. light: 10,
  238. };
  239. return config;
  240. };