Skip to content

Commit 0f37d77

Browse files
committed
Add additional informational logging to v2 api calls to capture match flow.
1 parent a97b59b commit 0f37d77

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/routes/v2/api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ router.post("/", basicRateLimit, async (req, res) => {
8888
let matchId: string = req.body?.matchid;
8989
const apiKey: string | undefined = req.get("Authorization");
9090
const eventType: Get5_OnEvent = req.body;
91-
91+
console.log("API.ts: Received event: ", eventType.event, " for match ID: ", matchId);
92+
console.log("API.ts: Full event data: ", req.body.toString());
9293
try {
9394
if (!apiKey) {
9495
return res.status(401).send({ message: "API key not provided." });
@@ -109,17 +110,21 @@ router.post("/", basicRateLimit, async (req, res) => {
109110

110111
const matchApiCheck: number = await Utils.checkApiKey(apiKey, matchId);
111112
if (eventType.event == "demo_upload_ended") {
113+
console.log("API.ts: Received demo upload ended event. Ignoring.");
112114
// Ignore demo_upload_ended event.
113115
return res.status(200).send({message: "Success"});
114116
} else if (eventType.event == "series_end") {
117+
console.log("API.ts: Received series end event.");
115118
// let forfeit: number = event.
116119
// Match is finalized, this is usually called after a cancel so we just ignore the value with a 200 response.
117120
if (matchApiCheck == 2) {
121+
console.log("API.ts : Match already finalized or cancelled, ignoring.");
118122
return res.status(200).send({
119123
message:
120124
"Match already finalized or and invalid API key has been given."
121125
});
122126
} else if (matchApiCheck == 1) {
127+
console.log("API.ts : Invalid API key given, ignoring.");
123128
console.error(
124129
"Match already finalized or and invalid API key has been given."
125130
);
@@ -130,6 +135,7 @@ router.post("/", basicRateLimit, async (req, res) => {
130135
}
131136
} else {
132137
if (matchApiCheck == 2 || matchApiCheck == 1) {
138+
console.log("API.ts : series_end was not given, but match is either cancelled or finalized. ", matchApiCheck.toString());
133139
console.error(
134140
"Match already finalized or and invalid API key has been given."
135141
);
@@ -195,6 +201,7 @@ router.post("/", basicRateLimit, async (req, res) => {
195201
);
196202
break;
197203
default:
204+
console.log(`API.ts: Event ${eventType.event} is not implemented.`);
198205
res.status(202).send({message: `Event ${eventType.event} is not implemented.`});
199206
break;
200207
}

0 commit comments

Comments
 (0)