config.default.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. 'use strict';
  2. const path = require('path');
  3. module.exports = appInfo => {
  4. const config = {};
  5. // 数据库配置
  6. config.mysql = {
  7. client: {
  8. // host
  9. host: '127.0.0.1',
  10. // 端口号
  11. port: '3306',
  12. // 用户名
  13. user: 'zh_calc',
  14. // 密码
  15. password: 'zh@)!(3850calc',
  16. // 数据库名
  17. database: 'calculation',
  18. },
  19. // 是否加载到 app 上,默认开启
  20. app: true,
  21. // 是否加载到 agent 上,默认关闭
  22. agent: false,
  23. };
  24. // 表名前缀
  25. config.tablePrefix = 'zh_';
  26. // redis设置
  27. config.redis = {
  28. client: {
  29. host: '127.0.0.1',
  30. port: '6379',
  31. password: 'zh@)!(3850sc',
  32. db: '0',
  33. },
  34. agent: true,
  35. version: '1.0.0',
  36. };
  37. // should change to your own
  38. config.keys = appInfo.name + '_1503910434503_882';
  39. // view相关
  40. config.view = {
  41. mapping: {
  42. '.ejs': 'ejs',
  43. },
  44. root: [
  45. path.join(appInfo.baseDir, 'app/view'),
  46. ].join(','),
  47. cache: false,
  48. };
  49. // 分页相关
  50. config.pageSize = 15;
  51. // 中间件
  52. config.middleware = ['gzip', 'urlParse', 'sortFilter', 'autoLogger'];
  53. // session配置
  54. config.session = {
  55. key: 'ZHC_SESS',
  56. maxAge: 3600 * 1000, // 1小时
  57. httpOnly: true,
  58. encrypt: true,
  59. };
  60. // session使用redis
  61. exports.sessionRedis = {
  62. name: 'session',
  63. };
  64. // 缓存时间
  65. config.cacheTime = 3600 * 24 * 31; // 31天 计量一期的时间,估计为1月
  66. // 安全性配置
  67. config.security = {
  68. csrf: {
  69. ignoreJSON: false, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
  70. },
  71. };
  72. // 发送短信相关
  73. config.sms = {
  74. // account: '710030',
  75. // password: 'w7pRhJ',
  76. // extno: '10690587',
  77. authKey: 'fb5ef483e44b9556512a9febef376051',
  78. };
  79. // geetest验证码key
  80. config.geetest = {
  81. id: '23c50f6711966f744c93a70167c8e0a4',
  82. key: '9b67989994f9def437ea68bb495f0162',
  83. };
  84. // 前端验证
  85. config.jsValidator = {
  86. client: {},
  87. app: true,
  88. };
  89. config.filePath = '/etc/calc/files/';
  90. // 上传设置
  91. config.multipart = {
  92. whitelist: ['.json', '.txt',
  93. '.xls', '.xlsx',
  94. '.doc', '.docx',
  95. '.pdf',
  96. '.ppt', '.pptx',
  97. '.png', '.jpg', '.jpeg', '.gif', '.bmp',
  98. '.zip', '.rar', '.7z', ''],
  99. fileSize: '30mb',
  100. };
  101. // 是否压缩替换前端js
  102. config.min = true;
  103. config.version = '1.0.1';
  104. // 压缩设置
  105. config.gzip = {
  106. threshold: 2048,
  107. // 下载的url要用正则忽略
  108. ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)(\w*)/ig,
  109. };
  110. config.customLogger = {
  111. // 操作失败日志
  112. fail: {
  113. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'fail.log'),
  114. },
  115. // 以下为业务日志
  116. ledger: {
  117. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'ledger.log'),
  118. },
  119. stage: {
  120. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'stage.log'),
  121. },
  122. mixed: {
  123. file: path.join(appInfo.root, 'logs', appInfo.name, config.version, 'mixed.log'),
  124. }
  125. };
  126. config.bodyParser = {
  127. jsonLimit: '10mb',
  128. formLimit: '10mb',
  129. };
  130. config.etag = {
  131. weak: false,
  132. };
  133. return config;
  134. };