config.default.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.cluster = {
  24. listen: {
  25. port: 18099,
  26. },
  27. };
  28. config.cors = {
  29. origin: '*',
  30. allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
  31. };
  32. // add your user config here
  33. const userConfig = {
  34. // myAppName: 'egg',
  35. };
  36. // 解除上传大小限制
  37. config.bodyParser = {
  38. jsonLimit: '100mb',
  39. formLimit: '100mb',
  40. };
  41. // 解除文件上传大小限制
  42. config.multipart = {
  43. fileSize: '50mb',
  44. mode: 'stream',
  45. fileExtensions: [ '.xls', '.png', '.jpg', '.doc', '.xlsx', '.docx', '.rar', '.zip', '.7z', '.pdf' ], // 扩展几种上传的文件格式
  46. };
  47. // jwt密钥
  48. config.jwt = {
  49. secret: '123456',
  50. };
  51. config.userSecret = '123456';
  52. config.filespath = '/var/www/jjzh';
  53. // 数据库配置
  54. config.mongoose = {
  55. url: 'mongodb://127.0.0.1:27017/cms',
  56. };
  57. // config.mongoose = {
  58. // url: 'mongodb://127.0.0.1:27018/cms',
  59. // options: {
  60. // user: 'root',
  61. // pass: 'cms@cc-lotus',
  62. // authSource: 'admin',
  63. // useNewUrlParser: true,
  64. // useCreateIndex: true,
  65. // useUnifiedTopology: true,
  66. // },
  67. // };
  68. // 异常捕获 路由拦截
  69. config.middleware = [ 'errorHandler' ];
  70. config.errorHandler = {
  71. match: '/api',
  72. };
  73. return {
  74. ...config,
  75. ...userConfig,
  76. };
  77. };