config.default.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. };
  159. config.etag = {
  160. weak: false,
  161. };
  162. config.wechatAll = {
  163. appid: 'wx1c1cd8bae5836439',
  164. appsecret: 'a35104f156faf19ab7a3ae4f990a1dd4',
  165. token: 'smartcost3850888',
  166. encodingAESKey: 'yjTsgluXZnsx5At4XjtOgeIZzmPuuFqoa3tLe25WxtC',
  167. payment: {
  168. partnerKey: '',
  169. mchId: '',
  170. notifyUrl: '',
  171. pfx: '',
  172. },
  173. modules: {
  174. message: true, // enable or disable co-wechat
  175. api: true, // enable or disable co-wechat-api
  176. oauth: true, // enable or disable co-wechat-oauth
  177. payment: false, // enable or disable co-wechat-payment
  178. },
  179. };
  180. // wx扫码登录
  181. config.wxCode = {
  182. appid: 'wx3d5394b238a3bc9a',
  183. appsecret: '457d64c55f48f57cd22eca47e53d15cb',
  184. };
  185. // 企业微信代开发模板信息
  186. config.qywx = {
  187. suiteID: 'dk10a5f6b6a68d6ed4',
  188. suiteSecret: 'TWmb3K-74VGv-X-ugox3T3yGPc_aa0ci4uNkIlmMaRA',
  189. token: 'NRPyXeKObE3Nesc',
  190. encodingAESKey: 'a6zuXvcHQlgdyY8465AbVpMpSKF0HMf0aMMxRthuOiq',
  191. };
  192. config.proxy = true;
  193. config.hisOssPath = 'prod/';
  194. config.stashOssPath = 'stash/prod/';
  195. config.oss = {
  196. clients: {
  197. signPdf: {
  198. bucket: 'measure-sign-pdf',
  199. },
  200. fujian: {
  201. bucket: 'jiliang-saas',
  202. },
  203. his: {
  204. bucket: 'jiliang-his',
  205. }
  206. },
  207. default: {
  208. accessKeyId: 'LTAIALMjBHOs9PLA',
  209. accessKeySecret: 'HSnULQs87wAJhcziAdyRv3GZ4EYctc',
  210. endpoint: 'oss-cn-shenzhen-internal.aliyuncs.com',
  211. timeout: '60s',
  212. },
  213. };
  214. config.fujianOssPath = 'https://jiliang-saas-oss-cdn.smartcost.com.cn/';
  215. config.fujianOssFolder = '';
  216. config.syncUrl = 'http://sync.jl.smartcost.com.cn/';
  217. // 项目管理跳转路径
  218. config.managementPath = 'https://pm.smartcost.com.cn';
  219. config.managementProxyPath = 'https://pm.smartcost.com.cn';
  220. config.url3f = '/3f';
  221. return config;
  222. };