config.default.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 = appInfo.name + '_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: ['.json', '.txt',
  110. '.xls', '.xlsx',
  111. '.doc', '.docx',
  112. '.pdf',
  113. '.ppt', '.pptx',
  114. '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.cad', '.dwg',
  115. '.zip', '.rar', '.7z', ''],
  116. fileSize: '100mb',
  117. fields: '15',
  118. };
  119. // 是否压缩替换前端js
  120. config.min = true;
  121. const file = path.join(__dirname, 'version');
  122. if (fs.existsSync(file)) {
  123. const versionStr = fs.readFileSync(file, 'utf8');
  124. config.version = versionStr.split('\n')[0];
  125. } else {
  126. config.version = '1.0.5';
  127. }
  128. // 压缩设置
  129. config.gzip = {
  130. threshold: 2048,
  131. // 下载的url要用正则忽略
  132. ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)|(\/download\/compresse-file)|(\/compresse\/file)|(\/im-file\/download)(\w*)/ig,
  133. };
  134. config.customLogger = {
  135. // 操作失败日志
  136. fail: {
  137. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'fail.log'),
  138. },
  139. // 以下为业务日志
  140. ledger: {
  141. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'ledger.log'),
  142. },
  143. stage: {
  144. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'stage.log'),
  145. },
  146. mixed: {
  147. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'mixed.log'),
  148. },
  149. finish: {
  150. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'finish.log'),
  151. },
  152. warning: {
  153. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'warning.log'),
  154. },
  155. out: {
  156. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'out.log'),
  157. }
  158. };
  159. config.bodyParser = {
  160. jsonLimit: '10mb',
  161. formLimit: '10mb',
  162. queryString: {
  163. arrayLimit: 100,
  164. depth: 5,
  165. parameterLimit: 1000,
  166. },
  167. enableTypes: ['json', 'form', 'text'],
  168. extendTypes: {
  169. text: ['text/xml', 'application/xml'],
  170. },
  171. };
  172. config.etag = {
  173. weak: false,
  174. };
  175. config.wechatAll = {
  176. appid: 'wx1c1cd8bae5836439',
  177. appsecret: 'a35104f156faf19ab7a3ae4f990a1dd4',
  178. token: 'smartcost3850888',
  179. encodingAESKey: 'yjTsgluXZnsx5At4XjtOgeIZzmPuuFqoa3tLe25WxtC',
  180. payment: {
  181. partnerKey: '',
  182. mchId: '',
  183. notifyUrl: '',
  184. pfx: '',
  185. },
  186. modules: {
  187. message: true, // enable or disable co-wechat
  188. api: true, // enable or disable co-wechat-api
  189. oauth: true, // enable or disable co-wechat-oauth
  190. payment: false, // enable or disable co-wechat-payment
  191. },
  192. };
  193. // wx扫码登录
  194. config.wxCode = {
  195. appid: 'wx3d5394b238a3bc9a',
  196. appsecret: '457d64c55f48f57cd22eca47e53d15cb',
  197. };
  198. // 企业微信代开发模板信息
  199. config.qywx = {
  200. suiteID: 'dk1f00b68c19d825ba',
  201. suiteSecret: 'xYP1oRNDa5BcdNXxJXgZjvWpwuECWki5RLdA-xhdeRo',
  202. token: 'NRPyXeKObE3Nesc',
  203. encodingAESKey: 'a6zuXvcHQlgdyY8465AbVpMpSKF0HMf0aMMxRthuOiq',
  204. };
  205. config.proxy = true;
  206. config.hisOssPath = 'prod/';
  207. config.stashOssPath = 'stash/prod/';
  208. config.oss = {
  209. clients: {
  210. signPdf: {
  211. bucket: 'measure-sign-pdf',
  212. },
  213. fujian: {
  214. bucket: 'jiliang-saas',
  215. },
  216. his: {
  217. bucket: 'jiliang-his',
  218. }
  219. },
  220. default: {
  221. accessKeyId: 'LTAIALMjBHOs9PLA',
  222. accessKeySecret: 'HSnULQs87wAJhcziAdyRv3GZ4EYctc',
  223. endpoint: 'oss-cn-shenzhen-internal.aliyuncs.com',
  224. timeout: '60s',
  225. },
  226. };
  227. config.fujianOssPath = 'https://jiliang-saas-oss-cdn.smartcost.com.cn/';
  228. config.fujianOssFolder = '';
  229. config.syncUrl = 'https://jl-sync.smartcost.com.cn/';
  230. // 项目管理跳转路径
  231. config.managementPath = 'https://pm.smartcost.com.cn';
  232. config.managementProxyPath = 'https://pm.smartcost.com.cn';
  233. config.url3f = '/3f';
  234. config.table_depart = {
  235. heavy: 100,
  236. light: 10,
  237. };
  238. return config;
  239. };