Skip to content

Commit 3d46cec

Browse files
committed
wip
1 parent 8c31e82 commit 3d46cec

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

src/matches/match-relay/match-relay.service.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,17 @@ export class MatchRelayService {
3838
response: Response,
3939
matchId: string,
4040
fragmentIndex: number,
41-
field: string,
41+
field: "start" | "full" | "delta",
4242
) {
4343
const broadcast = this.broadcasts[matchId];
4444
if (!broadcast) {
45-
this.relayError(
46-
response,
47-
404,
48-
`Broadcast not found for matchId ${matchId}`,
49-
);
45+
this.relayError(response, 404, `broadcast not found`);
5046
return;
5147
}
5248

5349
const fragment = broadcast[fragmentIndex];
5450
if (!fragment) {
55-
response.writeHead(404, "Fragment not found");
51+
response.writeHead(404, "fragment not found");
5652
response.end();
5753
return;
5854
}
@@ -71,19 +67,14 @@ export class MatchRelayService {
7167

7268
const broadcast = this.broadcasts[matchId];
7369
if (!broadcast) {
74-
this.relayError(
75-
response,
76-
404,
77-
`Broadcast not found for matchId ${matchId}`,
78-
);
70+
this.relayError(response, 404, `broadcast not found`);
7971
return;
8072
}
8173

8274
const match_field_0 = broadcast[0];
8375
// Check if start fragment exists at index 0
8476
if (match_field_0 == null || match_field_0.start?.data == null) {
85-
response.writeHead(404, "Broadcast has not started yet");
86-
response.end();
77+
this.relayError(response, 404, `broadcast has not started yet`);
8778
return;
8879
}
8980

@@ -121,8 +112,11 @@ export class MatchRelayService {
121112
}
122113

123114
if (!fragment) {
124-
response.writeHead(405, "Fragment not found, please check back soon");
125-
response.end();
115+
this.relayError(
116+
response,
117+
405,
118+
`fragment not found, please check back soon`,
119+
);
126120
return;
127121
}
128122

@@ -161,7 +155,7 @@ export class MatchRelayService {
161155
public postField(
162156
request: Request,
163157
response: Response,
164-
field: string,
158+
field: "start" | "full" | "delta",
165159
matchId: string,
166160
fragmentIndex: number,
167161
): void {

0 commit comments

Comments
 (0)