config.default.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* eslint valid-jsdoc: "off" */
  2. 'use strict';
  3. /**
  4. * @param {Egg.EggAppInfo} appInfo app info
  5. */
  6. module.exports = appInfo => {
  7. /**
  8. * built-in config
  9. * @type {Egg.EggAppConfig}
  10. **/
  11. const config = exports = {};
  12. // use for cookie sign key, should change to your own and keep security
  13. config.keys = appInfo.name + '_1618984590142_9986';
  14. // add your middleware config here
  15. config.middleware = [];
  16. // 关闭安全防范
  17. config.security = {
  18. csrf: {
  19. enable: false,
  20. ignoreJSON: true,
  21. },
  22. };
  23. config.cors = {
  24. origin: '*',
  25. allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
  26. };
  27. // add your user config here
  28. const userConfig = {
  29. // myAppName: 'egg',
  30. };
  31. // 解除上传大小限制
  32. config.bodyParser = {
  33. jsonLimit: '100mb',
  34. formLimit: '100mb',
  35. };
  36. // 解除文件上传大小限制
  37. config.multipart = {
  38. fileSize: '50mb',
  39. mode: 'stream',
  40. fileExtensions: [ '.xls', '.png', '.jpg', '.doc', '.xlsx', '.docx', '.rar', '.zip', '.7z', '.pdf' ], // 扩展几种上传的文件格式
  41. };
  42. // jwt密钥
  43. config.jwt = {
  44. secret: '123456',
  45. };
  46. config.userSecret = '123456';
  47. config.filespath = '/var/www/jjzh';
  48. // 数据库配置
  49. config.mongoose = {
  50. url: 'mongodb://172.17.116.7:27018/cms',
  51. options: {
  52. user: 'root',
  53. pass: 'cms@cc-lotus',
  54. authSource: 'admin',
  55. useNewUrlParser: true,
  56. useCreateIndex: true,
  57. useUnifiedTopology: true,
  58. },
  59. };
  60. // config.mongoose = {
  61. // url: 'mongodb://127.0.0.1:27017/example',
  62. // options: {
  63. // // user: 'root',
  64. // // pass: 'cms@cc-lotus',
  65. // // authSource: 'admin',
  66. // // useNewUrlParser: true,
  67. // // useCreateIndex: true,
  68. // // useUnifiedTopology: true,
  69. // },
  70. // };
  71. // 异常捕获 路由拦截
  72. config.middleware = [ 'errorHandler' ];
  73. config.errorHandler = {
  74. match: '/api',
  75. };
  76. return {
  77. ...config,
  78. ...userConfig,
  79. };
  80. };