Skip to content

Commit

Permalink
fix channel response
Browse files Browse the repository at this point in the history
  • Loading branch information
edstevo committed Mar 31, 2021
1 parent 0ba5af2 commit 4f1f80d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@nestjs/common": "^7.5.1",
"@nestjs/core": "^7.5.1",
"@nestjs/platform-express": "^7.5.1",
"@types/axios": "^0.14.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.3"
Expand Down
8 changes: 5 additions & 3 deletions src/channels/http/http.channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import {
} from '@nestjs/common';
import { HttpNotification } from './http-notification.interface';
import { NestJsNotificationChannel } from '../notification-channel.interface';
import { AxiosResponse } from 'axios';

@Injectable()
export class HttpChannel implements NestJsNotificationChannel {

constructor(private readonly httpService: HttpService) {}

/**
* Send the given notification
* @param notification
*/
public async send(notification: HttpNotification): Promise<void> {
public async send(
notification: HttpNotification,
): Promise<AxiosResponse<any>> {
const message = this.getData(notification);
await this.httpService.post(notification.httpUrl(), message).toPromise();
return this.httpService.post(notification.httpUrl(), message).toPromise();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/channels/notification-channel.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface NestJsNotificationChannel {
* Send the given notification
* @param notification
*/
send(notification: NestJsNotification): Promise<void>;
send(notification: NestJsNotification): Promise<any>;
}
7 changes: 5 additions & 2 deletions src/channels/sendgrid/sendgrid.channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { SendGridNotification } from './sendgrid-notification.interface';
import { NestJsNotificationChannel } from '../notification-channel.interface';
import { SendGridApiUrl } from './constants';
import { AxiosResponse } from 'axios';

@Injectable()
export class SendGridChannel implements NestJsNotificationChannel {
Expand All @@ -15,9 +16,11 @@ export class SendGridChannel implements NestJsNotificationChannel {
* Send the given notification
* @param notification
*/
public async send(notification: SendGridNotification): Promise<void> {
public async send(
notification: SendGridNotification,
): Promise<AxiosResponse<any>> {
const data = this.getData(notification);
await this.httpService
return this.httpService
.post(SendGridApiUrl, data, {
headers: {
Authorization: notification.sendGridApiKey(),
Expand Down

0 comments on commit 4f1f80d

Please sign in to comment.