Skip to content

Commit

Permalink
fix(module): updates decorators type to accept a class
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdo29 committed Jul 18, 2020
1 parent 8f3ab87 commit 1bc3df7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Inject } from '@nestjs/common';
import { createProviderToken } from '../ogma.provider';
import { Type } from '../interfaces';

export const OgmaLogger = (topic: string | (() => any)) =>
export const OgmaLogger = (topic: string | (() => any) | Type<any>) =>
Inject(createProviderToken(typeof topic === 'function' ? topic.name : topic));
4 changes: 3 additions & 1 deletion packages/nestjs-module/src/ogma.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function createProviderToken(topic: string): string {
return OGMA_SERVICE_TOKEN + ':' + topic;
}

export function createLoggerProviders(topic: string | (() => any)): Provider[] {
export function createLoggerProviders(
topic: string | (() => any) | Type<any>,
): Provider[] {
topic = typeof topic === 'function' ? topic.name : topic;
const token = createProviderToken(topic);
return [
Expand Down

0 comments on commit 1bc3df7

Please sign in to comment.