config.default.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* eslint valid-jsdoc: 'off' */
  2. 'use strict';
  3. /**
  4. * @param {Egg.EggAppInfo} appInfo app info
  5. */
  6. const path = require('path');
  7. const { sep } = require('path');
  8. module.exports = appInfo => {
  9. /**
  10. * built-in config
  11. * @type {Egg.EggAppConfig}
  12. **/
  13. const config = exports = {};
  14. // use for cookie sign key, should change to your own and keep security
  15. config.keys = appInfo.name + '_1636338746694_9710';
  16. // add your middleware config here
  17. config.middleware = [];
  18. // add your user config here
  19. const userConfig = {
  20. // myAppName: 'egg',
  21. };
  22. // 安全配置
  23. config.security = {
  24. csrf: {
  25. // ignoreJSON: true, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
  26. enable: false,
  27. },
  28. };
  29. config.cluster = {
  30. listen: {
  31. port: 18093,
  32. },
  33. };
  34. // 数据库配置
  35. config.mongoose = {
  36. // url: 'mongodb://127.0.0.1:27018/Microservices',
  37. url: 'mongodb://172.17.116.7:27018/Microservices',
  38. options: {
  39. user: 'root',
  40. pass: 'cms@cc-lotus',
  41. // pass: 'Ziyouyanfa#@!',
  42. authSource: 'admin',
  43. useNewUrlParser: true,
  44. useCreateIndex: true,
  45. },
  46. };
  47. // 文件存储路径
  48. config.repos_root_path = `${appInfo.baseDir}${sep}upload`;
  49. config.root_path = `${appInfo.baseDir}`;
  50. // 是否启用持久化数据
  51. config.data_save = true;
  52. // 限制文件大小
  53. config.multipart = {
  54. mode: 'stream',
  55. fileSize: '5mb',
  56. fileExtensions: [ '.rtf', '.csv', '.odp', '.csv', '.ods', '.pptx', '.ppt', '.rar', '.7z', '.tar', '.gz', '.tar', '.gz', '.zip', '.doc', '.docx', '.xlsx', '.xls', '.jpg', '.jpeg', '.png', '.gif', '.bmp', '.svg', '.tiff', '.pdf', '.txt', '.mp4', '.avi', '.mov', '.wmv', '.flv', '.mkv', '.m4v' ], // 新增允许接收的文件后缀
  57. // whitelist: [], // 覆盖允许接收的文件后缀
  58. };
  59. config.logger = {
  60. level: 'DEBUG',
  61. };
  62. config.static = {
  63. // 静态化访问前缀,如:`http://127.0.0.1:7001/static/images/logo.png`
  64. prefix: '/upload',
  65. dir: path.join(appInfo.baseDir, 'upload'), // `String` or `Array:[dir1, dir2, ...]` 静态化目录,可以设置多个静态化目录
  66. dynamic: true, // 如果当前访问的静态资源没有缓存,则缓存静态文件,和`preload`配合使用;
  67. preload: false,
  68. maxAge: 31536000, // in prod env, 0 in other envs
  69. buffer: true, // in prod env, false in other envs
  70. };
  71. return {
  72. ...config,
  73. ...userConfig,
  74. };
  75. };