config.default.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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: 'root',
  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'];
  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: true, // 默认为 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. // 前端验证
  78. config.jsValidator = {
  79. client: {},
  80. app: true,
  81. };
  82. // 上传设置
  83. config.multipart = {
  84. whitelist: ['.xls', '.xlsx', '.json'],
  85. fileSize: '10mb',
  86. };
  87. // 是否压缩替换前端js
  88. config.min = true;
  89. return config;
  90. };