config.default.js 3.0 KB

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