Skip to content

Commit

Permalink
WIP Server side events
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Sep 8, 2023
1 parent 561923c commit 8c7b18b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/routes/events/events.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { EventsController } from './events.controller';

describe('EventsController', () => {
let controller: EventsController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [EventsController],
}).compile();

controller = module.get<EventsController>(EventsController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
13 changes: 13 additions & 0 deletions src/routes/events/events.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller, Param, Sse } from '@nestjs/common';
import { Observable } from 'rxjs';
import { EventsService } from './events.service';

@Controller('events')
export class EventsController {
constructor(private eventsService: EventsService) {}

@Sse('/sse/:safe')
sse(@Param('safe') safe: string): Observable<MessageEvent> {

Check warning on line 10 in src/routes/events/events.controller.ts

View workflow job for this annotation

GitHub Actions / lint

'safe' is defined but never used
return interval(1000).pipe(map((_) => ({ data: { hello: 'world' } })));

Check warning on line 11 in src/routes/events/events.controller.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used
}
}
2 changes: 0 additions & 2 deletions src/routes/events/events.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ describe('EventsService', () => {
webhookService = module.get<WebhookService>(WebhookService);
});



describe('listenToEvents', () => {
it('should return consumer tag', async () => {
const expected = 'exampleTag';
Expand Down

0 comments on commit 8c7b18b

Please sign in to comment.