(eventType: string, jsonPayload: object)
| 98 | * `:message-type` = `event`. |
| 99 | */ |
| 100 | export function encodeEventStreamMessage(eventType: string, jsonPayload: object): Buffer { |
| 101 | const headers: Record<string, string> = { |
| 102 | ":content-type": "application/json", |
| 103 | ":event-type": eventType, |
| 104 | ":message-type": "event", |
| 105 | }; |
| 106 | const payload = Buffer.from(JSON.stringify(jsonPayload), "utf8"); |
| 107 | return encodeEventStreamFrame(headers, payload); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Write a sequence of event-stream frames to an HTTP response with optional |
searching dependent graphs…