( clients: Set<http.ServerResponse>, channel: TChannel, event: DesktopEventMap[TChannel], )
| 42 | } |
| 43 | |
| 44 | function sendSseEvent<TChannel extends keyof DesktopEventMap>( |
| 45 | clients: Set<http.ServerResponse>, |
| 46 | channel: TChannel, |
| 47 | event: DesktopEventMap[TChannel], |
| 48 | ) { |
| 49 | const payload = JSON.stringify({ channel, event }) |
| 50 | for (const client of clients) { |
| 51 | client.write(`event: ${channel}\n`) |
| 52 | client.write(`data: ${payload}\n\n`) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | async function writeUniqueTextFile(directoryPath: string, fileName: string, content: string) { |
| 57 | const parsed = path.parse(fileName) |
no test coverage detected