https://github.com/sinuoslabs/nestjs-notification
NestJS notification system like laravel notification
https://github.com/sinuoslabs/nestjs-notification
channels nestjs notification notificationchannels
Last synced: 2 days ago
JSON representation
NestJS notification system like laravel notification
- Host: GitHub
- URL: https://github.com/sinuoslabs/nestjs-notification
- Owner: sinuoslabs
- License: mit
- Created: 2021-12-07T10:55:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-05-08T19:58:36.000Z (5 months ago)
- Last Synced: 2025-05-08T22:44:23.955Z (5 months ago)
- Topics: channels, nestjs, notification, notificationchannels
- Language: TypeScript
- Size: 1.32 MB
- Stars: 24
- Watchers: 1
- Forks: 3
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# NestJS Notification

[](https://badge.fury.io/js/@sinuos%2Fnestjs-notification)
## Description
NestJs Notifications is a flexible multi-channel notification service inspired by [Laravel Notifications](https://github.com/illuminate/notifications).
Notifications are short, informative messages that inform users of an event that occurred in your application.
For example, if you are writing a billing application, you can send a **"Bill Paid"** notification to your users via email and SMS channels.This module works with existing channels that you can find here: https://github.com/nestjs-notification-channels. You have the possibility to create your own custom channels.
## Installation
```bash
$ npm i @sinuos/nestjs-notification
```## Usage
### Declare module
```typescript
import { NestjsNotificationModule } from '@sinuos/nestjs-notification.module';@Module({
imports: [NestjsNotificationModule.register()],
})
export class AppModule {}
```### Channel
```typescript
import { Injectable } from '@nestjs/common';
import { INestjsNotificationChannel } from '@sinuos/nestjs-notification.service';@Injectable()
export class NexmoChannel implements INestjsNotificationChannel {
constructor() {}send(): Promise {
return Promise.resolve(undefined);
}
}
```### Notification
```typescript
import { NestJsNotification } from '@sinuos/nestjs-notification.service';export class InvoicPaidNotification implements NestJsNotification {
public sendToChannels() {
return [NexmoChannel];
}toNexmo() {
return new NexmoMessage();
}
}
```### Send notification
```typescript
import { Injectable } from '@nestjs/common';
import { NestjsNotificationService } from '@sinuos/nestjs-notification.service';@Injectable()
export class AppService {
constructor(private notification: NestjsNotificationService) {}notification() {
const notification = new InvoicePaidNotification();
this.notification.send(notification);
}
}
```## Based on
[Nestjs notification](https://github.com/edstevo/nestjs-notifications) by [edstevo](https://github.com/edstevo)
## License
NestJS's notification is [MIT licensed](LICENSE).