index.ts 851 B

12345678910111213141516171819202122232425
  1. import { Subject, from } from 'rxjs';
  2. import * as fs from 'fs'
  3. export * from './services/fis.retransmission.service';
  4. export * from './services/server-client.service';
  5. const messagesJSON: any = fs.readFileSync('payload.json')
  6. let parsedMessages = JSON.parse(messagesJSON)
  7. function generateFakeStreamResponse(request: any): Subject<any> {
  8. let res: Subject<any> = new Subject()
  9. from(parsedMessages.slice(0, 10)).subscribe({
  10. next: element => {
  11. let message = {
  12. id: request.id,
  13. message: element
  14. }
  15. res.next(message)
  16. },
  17. error: error => console.error(error),
  18. complete: () => console.log(`Stream response for ${request.id} has been prepared.`)
  19. })
  20. return res
  21. }
  22. generateFakeStreamResponse({ id: '123', message: 'DOnt lie to me boy' }).subscribe((e => console.log(e)))