notifme-sdk
notifme-sdk copied to clipboard
Nestjs Implementation
Hello is there a Nestjs Wrapper for Notifme?. Or can you optionally give me pointers on how to implement this in Nestjs?
Hi
I am doing the following
// message.module.ts
import NotifmeSdk from 'notifme-sdk'
@Module({
imports: [AppConfigModule],
controllers: [MessageController],
providers: [
MessageService,
{
provide: NotifmeSdk,
inject: [AppConfigService, Logger],
useFactory: (config: AppConfigService) => new NotifmeSdk(config.get('app.notifmeConfig'))
},
],
})
export class MessageModule {
}
Usage
// message.service.ts
import NotifmeSdk from 'notifme-sdk'
@Injectable()
export class MessageService {
constructor(
private readonly notifmeSdk: NotifmeSdk,
) {
}
public async send(channel: string, payload: any) {
// ...
const response = await this.notifmeSdk.send({ [channel]: payload })
// ...
}
}