config.default.js 7.3 KB

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