Skip to content

Commit d9ea194

Browse files
committed
Merge branch 'staging' into jackshim415/lvt-28-public-api
2 parents e73aec5 + 431a514 commit d9ea194

4 files changed

Lines changed: 73 additions & 7 deletions

File tree

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ app.use(express.static(path.resolve("public")));
2626
app.use(posthogReporter);
2727

2828
// API entry point
29-
app.use("/v1", routes);
29+
app.use("/v1", routes); //theo was here
3030

3131
app.get("/status", (req, res) => {
3232
res.status(200).send("Server running");

src/handler/analysis/alliancePredictions/alliancePage.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ const config = {
3939
),
4040
}),
4141
),
42+
l1StartTime: z.array(z.number().nullable()),
43+
l2StartTime: z.array(z.number().nullable()),
44+
l3StartTime: z.array(z.number().nullable()),
45+
totalFuelOutputted: z.number(),
46+
totalBallThroughput: z.number(),
4247
}),
4348
usesDataSource: true,
4449
shouldCache: true,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Response } from "express";
2+
import { AuthenticatedRequest } from "../../../lib/middleware/requireAuth.js";
3+
import {
4+
dataSourceRuleSchema,
5+
dataSourceRuleToArray,
6+
} from "../../analysis/dataSourceRule.js";
7+
import z from "zod";
8+
import { allTeamNumbers } from "../../analysis/analysisConstants.js";
9+
import prismaClient from "../../../prismaClient.js";
10+
11+
export const getTeamEmail = async (
12+
req: AuthenticatedRequest,
13+
res: Response,
14+
): Promise<void> => {
15+
try {
16+
if (req.user.role !== "SCOUTING_LEAD") {
17+
res.status(403).send("Forbidden");
18+
return;
19+
}
20+
21+
const teamEmail = await prismaClient.registeredTeam.findUnique({
22+
where: { number: req.user.teamNumber },
23+
select: { email: true },
24+
});
25+
26+
if (!teamEmail) {
27+
res.status(404).send("Team email not found");
28+
return;
29+
}
30+
31+
res.status(200).send(teamEmail.email);
32+
} catch (error) {
33+
console.error(error);
34+
res.status(500).send(error);
35+
}
36+
};

src/routes/manager/settings.routes.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getTournamentSource } from "../../handler/manager/settings/getTournamen
99
import { addTournamentSource } from "../../handler/manager/settings/addTournamentSource.js";
1010
import { registry } from "../../lib/openapi.js";
1111
import { z } from "zod";
12+
import { getTeamEmail } from "../../handler/manager/settings/getTeamEmail.js";
1213

1314
const updateTeamEmails = rateLimit({
1415
windowMs: 2 * 60 * 1000,
@@ -38,7 +39,10 @@ registry.registerPath({
3839
},
3940
},
4041
responses: {
41-
200: { description: "Updated", content: { "text/plain": { schema: z.string() } } },
42+
200: {
43+
description: "Updated",
44+
content: { "text/plain": { schema: z.string() } },
45+
},
4246
400: { description: "Invalid request" },
4347
401: { description: "Unauthorized" },
4448
500: { description: "Server error" },
@@ -89,7 +93,10 @@ registry.registerPath({
8993
},
9094
},
9195
responses: {
92-
200: { description: "Added", content: { "text/plain": { schema: z.string() } } },
96+
200: {
97+
description: "Added",
98+
content: { "text/plain": { schema: z.string() } },
99+
},
93100
400: { description: "Invalid request" },
94101
401: { description: "Unauthorized" },
95102
403: { description: "Not affiliated with a team" },
@@ -104,7 +111,10 @@ registry.registerPath({
104111
tags: ["Manager - Settings"],
105112
summary: "Get tournament source",
106113
responses: {
107-
200: { description: "Tournament source", content: { "application/json": { schema: z.array(z.string()) } } },
114+
200: {
115+
description: "Tournament source",
116+
content: { "application/json": { schema: z.array(z.string()) } },
117+
},
108118
401: { description: "Unauthorized" },
109119
500: { description: "Server error" },
110120
},
@@ -116,9 +126,20 @@ registry.registerPath({
116126
path: "/v1/manager/settings/tournamentsource",
117127
tags: ["Manager - Settings"],
118128
summary: "Add tournament source",
119-
request: { body: { content: { "application/json": { schema: z.object({ tournaments: z.array(z.string()) }) } } } },
129+
request: {
130+
body: {
131+
content: {
132+
"application/json": {
133+
schema: z.object({ tournaments: z.array(z.string()) }),
134+
},
135+
},
136+
},
137+
},
120138
responses: {
121-
200: { description: "Added", content: { "text/plain": { schema: z.string() } } },
139+
200: {
140+
description: "Added",
141+
content: { "text/plain": { schema: z.string() } },
142+
},
122143
400: { description: "Invalid request" },
123144
401: { description: "Unauthorized" },
124145
500: { description: "Server error" },
@@ -133,7 +154,10 @@ registry.registerPath({
133154
summary: "Update team email",
134155
request: { query: z.object({ email: z.string().email() }) },
135156
responses: {
136-
200: { description: "Verification sent", content: { "text/plain": { schema: z.string() } } },
157+
200: {
158+
description: "Verification sent",
159+
content: { "text/plain": { schema: z.string() } },
160+
},
137161
400: { description: "Invalid request" },
138162
401: { description: "Unauthorized" },
139163
404: { description: "Team not found" },
@@ -153,6 +177,7 @@ router.post("/teamsource", addTeamSource);
153177
router.get("/tournamentsource", getTournamentSource);
154178
router.post("/tournamentsource", addTournamentSource);
155179

180+
router.get("/teamemail", getTeamEmail);
156181
router.put("/teamemail", updateTeamEmails, updateTeamEmail);
157182

158183
export default router;

0 commit comments

Comments
 (0)