service.js 639 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const path = require('path');
  3. module.exports = {
  4. /**
  5. * Load app/service
  6. * @function EggLoader#loadService
  7. * @param {Object} opt - LoaderOptions
  8. * @since 1.0.0
  9. */
  10. loadService(opt) {
  11. this.timing.start('Load Service');
  12. // 载入到 app.serviceClasses
  13. opt = Object.assign({
  14. call: true,
  15. caseStyle: 'lower',
  16. fieldClass: 'serviceClasses',
  17. directory: this.getLoadUnits().map(unit => path.join(unit.path, 'app/service')),
  18. }, opt);
  19. const servicePaths = opt.directory;
  20. this.loadToContext(servicePaths, 'service', opt);
  21. this.timing.end('Load Service');
  22. },
  23. };