Skip to content

Commit

Permalink
Revert "Fixed NextJS build (take 3)"
Browse files Browse the repository at this point in the history
This reverts commit 16f2518.
  • Loading branch information
DragonXDev committed Mar 1, 2024
1 parent 94a4326 commit 3df7f75
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions packages/api/src/router/tba.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";

export const tbaRouter = createTRPCRouter({
teamEvents: publicProcedure
.input(z.object({ teamKey: z.string(), year: z.number() }))
.input(z.object({ teamKey: z.string() }))
.input(z.object({ year: z.number() }))
.query(async ({ input }) => {
const response = await axios.get(
`https://www.thebluealliance.com/api/v3/team/${input.teamKey}/events/${input.year}`,
// `https://www.thebluealliance.com/api/v3/team/${input.teamKey}/events/`,
{
headers: {
"X-TBA-Auth-Key":
Expand All @@ -19,19 +21,25 @@ export const tbaRouter = createTRPCRouter({
);

const extractedData = (
response.data as { event_code: string; key: string }[]
).map((event: { event_code: string; key: string }) => ({
response.data as { event_code: string; key: string; name: string }[]
).map((event: { event_code: string; name: string }) => ({
event_code: event.event_code,
key: event.key,
name: event.name,
}));

return extractedData as { event_code: string; key: string }[];
return extractedData as {
event_code: string;
key: string;
name: string;
}[];
}),
eventMatches: publicProcedure
.input(z.object({ teamKey: z.string() }))
.input(z.object({ eventKey: z.string() }))
.query(async ({ input }) => {
const response = await axios.get(
`https://www.thebluealliance.com/api/v3/event/${input}/matches`,
`https://www.thebluealliance.com/api/v3/team/${input.teamKey}/event/${input.eventKey}/matches/simple`,
{
headers: {
"X-TBA-Auth-Key":
Expand All @@ -41,7 +49,7 @@ export const tbaRouter = createTRPCRouter({
);
const extractedData2 = (
response.data as {
match_number: string;
match_number: number;
key: string;
alliances: {
red: { team_keys: [string, string, string] };
Expand All @@ -50,7 +58,7 @@ export const tbaRouter = createTRPCRouter({
}[]
).map(
(match: {
match_number: string;
match_number: number;
key: string;
alliances: {
red: { team_keys: [string, string, string] };
Expand All @@ -63,12 +71,6 @@ export const tbaRouter = createTRPCRouter({
// predicted_time: match.predicted_time,
}),
);
return extractedData2 as {
match_num: string;
alliances: {
red: { team_keys: [string, string, string] };
blue: { team_keys: [string, string, string] };
};
}[];
return extractedData2;
}),
});

0 comments on commit 3df7f75

Please sign in to comment.