Skip to content

Commit ef01df7

Browse files
committed
Migrate NotificationStrategy
1 parent b4e156b commit ef01df7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/components/notifications/notification.service.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { DiscoveryService } from '@golevelup/nestjs-discovery';
21
import {
32
forwardRef,
43
Inject,
@@ -13,6 +12,7 @@ import {
1312
ServerException,
1413
type UnsecuredDto,
1514
} from '~/common';
15+
import { MetadataDiscovery } from '~/core/discovery';
1616
import {
1717
type MarkNotificationReadArgs,
1818
type Notification,
@@ -62,7 +62,7 @@ export class NotificationServiceImpl
6262
>;
6363
readonly ready = new ((Event as any).default as typeof Event)();
6464

65-
constructor(private readonly discovery: DiscoveryService) {
65+
constructor(private readonly discovery: MetadataDiscovery) {
6666
super();
6767
}
6868

@@ -88,11 +88,8 @@ export class NotificationServiceImpl
8888
}
8989

9090
async onModuleInit() {
91-
const discovered = await this.discovery.providersWithMetaAtKey<
92-
ResourceShape<Notification>
93-
>(NotificationStrategy.KEY);
94-
this.strategyMap = mapEntries(discovered, ({ meta, discoveredClass }) => {
95-
const { instance } = discoveredClass;
91+
const discovered = this.discovery.discover(NotificationStrategy).classes();
92+
this.strategyMap = mapEntries(discovered, ({ meta, instance }) => {
9693
if (!(instance instanceof INotificationStrategy)) {
9794
throw new ServerException(
9895
`Strategy for ${meta.name} does not implement INotificationStrategy`,

0 commit comments

Comments
 (0)