config.default.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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: 'root',
  14. // 密码
  15. password: 'smartcost',
  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: 'test',
  32. db: '0',
  33. },
  34. agent: true,
  35. };
  36. // should change to your own
  37. config.keys = appInfo.name + '_1503910434503_882';
  38. // view相关
  39. config.view = {
  40. mapping: {
  41. '.ejs': 'ejs',
  42. },
  43. root: [
  44. path.join(appInfo.baseDir, 'app/view'),
  45. ].join(','),
  46. cache: false,
  47. };
  48. // 分页相关
  49. config.pageSize = 15;
  50. // 中间件
  51. config.middleware = ['urlParse', 'sortFilter', 'autoLogger'];
  52. // session配置
  53. config.session = {
  54. key: 'ZHC_SESS',
  55. maxAge: 3600 * 1000, // 1小时
  56. httpOnly: true,
  57. encrypt: true,
  58. };
  59. // session使用redis
  60. exports.sessionRedis = {
  61. name: 'session',
  62. };
  63. // 缓存时间
  64. config.cacheTime = 1800;
  65. // 安全性配置
  66. config.security = {
  67. csrf: {
  68. ignoreJSON: false, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
  69. },
  70. };
  71. // 发送短信相关
  72. config.sms = {
  73. account: '710030',
  74. password: 'w7pRhJ',
  75. extno: '10690587',
  76. authKey: 'fb5ef483e44b9556512a9febef376051',
  77. };
  78. // geetest验证码key
  79. config.geetest = {
  80. id: '23c50f6711966f744c93a70167c8e0a4',
  81. key: '9b67989994f9def437ea68bb495f0162',
  82. };
  83. // 前端验证
  84. config.jsValidator = {
  85. client: {},
  86. app: true,
  87. };
  88. // 上传设置
  89. config.multipart = {
  90. whitelist: ['.json', '.txt',
  91. '.xls', '.xlsx',
  92. '.doc', '.docx',
  93. '.pdf',
  94. '.png', '.jpg', '.jpeg', '.gif', '.bmp',
  95. '.zip', '.rar', '.7z'],
  96. fileSize: '30mb',
  97. };
  98. // 是否压缩替换前端js
  99. config.min = true;
  100. config.version = '1.0.0';
  101. // 压缩设置
  102. config.gzip = {
  103. threshold: 1024,
  104. };
  105. config.customLogger = {
  106. // 操作失败日志
  107. fail: {
  108. file: path.join(appInfo.root, 'logs/fail.log'),
  109. },
  110. // 以下为业务日志
  111. ledger: {
  112. file: path.join(appInfo.root, 'logs/ledger.log'),
  113. },
  114. stage: {
  115. file: path.join(appInfo.root, 'logs/stage.log'),
  116. },
  117. mixed: {
  118. file: path.join(appInfo.root, 'logs/mixed.log'),
  119. }
  120. };
  121. config.bodyParser = {
  122. jsonLimit: '10mb',
  123. formLimit: '10mb',
  124. };
  125. return config;
  126. };