config.default.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. const os = require('os');
  3. const path = require('path');
  4. module.exports = appInfo => {
  5. const config = {};
  6. /**
  7. * multipart parser options
  8. * @member Config#multipart
  9. * @property {String} mode - which mode to handle multipart request, default is `stream`, the hard way.
  10. * If set mode to `file`, it's the easy way to handle multipart request and save it to local files.
  11. * If you don't know the Node.js Stream work, maybe you should use the `file` mode to get started.
  12. * @property {String | RegExp | Function | Array} fileModeMatch - special url to use file mode when global `mode` is `stream`.
  13. * @property {Boolean} autoFields - Auto set fields to parts, default is `false`. Only work on `stream` mode.
  14. * If set true,all fields will be auto handle and can acces by `parts.fields`
  15. * @property {String} defaultCharset - Default charset encoding, don't change it before you real know about it
  16. * @property {Integer} fieldNameSize - Max field name size (in bytes), default is `100`
  17. * @property {String|Integer} fieldSize - Max field value size (in bytes), default is `100kb`
  18. * @property {Integer} fields - Max number of non-file fields, default is `10`
  19. * @property {String|Integer} fileSize - Max file size (in bytes), default is `10mb`
  20. * @property {Integer} files - Max number of file fields, default is `10`
  21. * @property {Array|Function} whitelist - The white ext file names, default is `null`
  22. * @property {Array} fileExtensions - Add more ext file names to the `whitelist`, default is `[]`
  23. * @property {String} tmpdir - The directory for temporary files. Only work on `file` mode.
  24. */
  25. config.multipart = {
  26. mode: 'stream',
  27. autoFields: false,
  28. defaultCharset: 'utf8',
  29. fieldNameSize: 100,
  30. fieldSize: '100kb',
  31. fields: 10,
  32. fileSize: '10mb',
  33. files: 10,
  34. fileExtensions: [],
  35. whitelist: null,
  36. allowArrayField: false,
  37. tmpdir: path.join(os.tmpdir(), 'egg-multipart-tmp', appInfo.name),
  38. cleanSchedule: {
  39. // run tmpdir clean job on every day 04:30 am
  40. // cron style see https://github.com/eggjs/egg-schedule#cron-style-scheduling
  41. cron: '0 30 4 * * *',
  42. disable: false,
  43. },
  44. };
  45. return config;
  46. };