Skip to content

Commit

Permalink
add service loader
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jun 15, 2024
1 parent 25b3deb commit 237fe26
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 180 deletions.
24 changes: 23 additions & 1 deletion src/loader/egg_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,29 @@ export class EggLoader {
}
/** end Custom loader */

/** start Service loader */
/**
* Load app/service
* @function EggLoader#loadService
* @param {Object} options - LoaderOptions
* @since 1.0.0
*/
loadService(options?: Partial<ContextLoaderOptions>) {
this.timing.start('Load Service');
// 载入到 app.serviceClasses
const servicePaths = this.getLoadUnits().map(unit => path.join(unit.path, 'app/service'));
options = {
call: true,
caseStyle: 'lower',
fieldClass: 'serviceClasses',
directory: servicePaths,
...options,
};
this.loadToContext(servicePaths, 'service', options as ContextLoaderOptions);
this.timing.end('Load Service');
}
/** end Service loader */

// Low Level API

/**
Expand Down Expand Up @@ -1351,7 +1374,6 @@ function isValidatePackageName(name: string) {
* https://medium.com/@leocavalcante/es6-multiple-inheritance-73a3c66d2b6b
*/
// const loaders = [
// require('./mixin/service'),
// require('./mixin/middleware'),
// require('./mixin/controller'),
// require('./mixin/router'),
Expand Down
151 changes: 0 additions & 151 deletions src/loader/mixin/extend.js

This file was deleted.

28 changes: 0 additions & 28 deletions src/loader/mixin/service.js

This file was deleted.

0 comments on commit 237fe26

Please sign in to comment.