config.default.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 = '/home/cms';
  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. // };
  64. // 异常捕获
  65. config.middleware = [ 'errorHandler' ];
  66. config.errorHandler = {
  67. match: '/api',
  68. };
  69. return {
  70. ...config,
  71. ...userConfig,
  72. };
  73. };