diff --git a/src/module_caller.ts b/src/module_caller.ts index 919aed6..2ec4db5 100644 --- a/src/module_caller.ts +++ b/src/module_caller.ts @@ -13,7 +13,7 @@ import type { ModuleHandler, ModuleCallable, Constructor } from './types.js' /** * The moduleCaller works around a very specific pattern we use with - * AdonisJS, ie to constructor classes and call methods using the + * AdonisJS, ie to construct classes and call methods using the * container. * * For example: Controllers of AdonisJS allows defining a controller @@ -116,6 +116,7 @@ export function moduleCaller(target: Constructor, method: string) { >(container?: T): ModuleHandler { if (container) { return { + name: `${target.name}.${method}`, async handle(...args: Args) { return container.call(await container.make(target), method, args) }, @@ -123,6 +124,7 @@ export function moduleCaller(target: Constructor, method: string) { } return { + name: `${target.name}.${method}`, async handle(resolver: ContainerResolver | Container, ...args: Args) { return resolver.call(await resolver.make(target), method, args) }, diff --git a/src/module_importer.ts b/src/module_importer.ts index 164d62c..e1c52c3 100644 --- a/src/module_importer.ts +++ b/src/module_importer.ts @@ -136,6 +136,7 @@ export function moduleImporter( if (container) { return { + name: importFn.name, async handle(...args: Args) { defaultExport = defaultExport || (await importDefault(importFn)) return container.call(await container.make(defaultExport), method, args) @@ -144,6 +145,7 @@ export function moduleImporter( } return { + name: importFn.name, async handle(resolver: ContainerResolver | Container, ...args: Args) { defaultExport = defaultExport || (await importDefault(importFn)) return resolver.call(await resolver.make(defaultExport), method, args) diff --git a/src/types.ts b/src/types.ts index 5980a16..24914ba 100644 --- a/src/types.ts +++ b/src/types.ts @@ -176,8 +176,10 @@ export type ModuleCallable = T extends undefined */ export type ModuleHandler = T extends undefined ? { + name?: string handle(resolver: ContainerResolver | Container, ...args: Args): Promise } : { + name?: string handle(...args: Args): Promise }