config.default.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* eslint valid-jsdoc: "off" */
  2. 'use strict';
  3. const { sep } = require('path');
  4. const ErrorConfig = require('./config.error.js');
  5. /**
  6. * @param {Egg.EggAppInfo} appInfo app info
  7. */
  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 + '_1577518454977_306';
  16. // add your middleware config here
  17. config.middleware = [];
  18. // add your user config here
  19. const userConfig = {
  20. // myAppName: 'egg',
  21. };
  22. config.cluster = {
  23. listen: {
  24. port: 8001,
  25. },
  26. };
  27. // 安全配置
  28. config.security = {
  29. csrf: {
  30. // ignoreJSON: true, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
  31. enable: false,
  32. },
  33. };
  34. config.cdn = {
  35. repos_root_path: `${appInfo.baseDir}${sep}upload`,
  36. repos_root_url: '',
  37. };
  38. config.wx = {
  39. wxdown: (appid, media_id) => `http://wx.cc-lotus.info/api.weixin.qq.com/cgi-bin/media/get?appid=${appid}&media_id=${media_id}`,
  40. };
  41. config.onerror = ErrorConfig;
  42. // 文件上传配置
  43. config.multipart = {
  44. whitelist: [
  45. '.jpg', '.jpeg', // image/jpeg
  46. '.gif',
  47. '.png',
  48. '.zip', '.rar', // 压缩文件
  49. '.txt',
  50. '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx',
  51. '.dbf',
  52. '.pdf',
  53. '.mp4',
  54. '.MP4',
  55. '.avi',
  56. '.AVI',
  57. '.rmvb',
  58. ],
  59. fileSize: '200mb',
  60. };
  61. return {
  62. ...config,
  63. ...userConfig,
  64. };
  65. };