Commit e767270d authored by nanahira's avatar nanahira

allow multiple provide

parent fad0e3a3
Pipeline #6343 passed with stages
in 27 seconds
{
"name": "koishi-nestjs",
"version": "1.2.0",
"version": "1.2.1",
"description": "Koishi.js as Nest.js Module",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
......
......@@ -174,5 +174,5 @@ export function WireContextService(name?: string): PropertyDecorator {
export function ProvideContextService(name: string): ClassDecorator {
Context.service(name as keyof Context.Services);
return SetMetadata(KoishiServiceProvideSym, name);
return SetExtraMetadata(KoishiServiceProvideSym, name);
}
......@@ -158,12 +158,14 @@ export class KoishiMetascanService {
}
private scanInstanceForProvidingContextService(ctx: Context, instance: any) {
const providingServiceName = this.reflector.get(
const providingServiceNames: string[] = this.reflector.get(
KoishiServiceProvideSym,
instance.constructor,
);
if (providingServiceName) {
ctx[providingServiceName] = instance;
if (providingServiceNames) {
for (const name of providingServiceNames) {
ctx[name] = instance;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment