config.default.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. authSource: 'admin',
  42. useNewUrlParser: true,
  43. useCreateIndex: true,
  44. },
  45. };
  46. // 文件存储路径
  47. config.repos_root_path = `${appInfo.baseDir}${sep}upload`;
  48. config.root_path = `${appInfo.baseDir}`;
  49. // 是否启用持久化数据
  50. config.data_save = true;
  51. // 限制文件大小
  52. config.multipart = {
  53. mode: 'stream',
  54. fileSize: '5mb',
  55. 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' ], // 新增允许接收的文件后缀
  56. // whitelist: [], // 覆盖允许接收的文件后缀
  57. };
  58. config.logger = {
  59. level: 'DEBUG',
  60. };
  61. config.static = {
  62. // 静态化访问前缀,如:`http://127.0.0.1:7001/static/images/logo.png`
  63. prefix: '/upload',
  64. dir: path.join(appInfo.baseDir, 'upload'), // `String` or `Array:[dir1, dir2, ...]` 静态化目录,可以设置多个静态化目录
  65. dynamic: true, // 如果当前访问的静态资源没有缓存,则缓存静态文件,和`preload`配合使用;
  66. preload: false,
  67. maxAge: 31536000, // in prod env, 0 in other envs
  68. buffer: true, // in prod env, false in other envs
  69. };
  70. return {
  71. ...config,
  72. ...userConfig,
  73. };
  74. };