config.default.js 8.1 KB

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