Skip to content

Commit 7b4dc8b

Browse files
committed
feat: add fn to getAllFixtures
1 parent c2f58e9 commit 7b4dc8b

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/api.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getEventFixtures } from "./api.js";
55
import {
66
BootstrapStaticSchema,
77
FixtureSchema,
8+
getAllFixtures,
89
getBootstrapStatic,
910
} from "./index.js";
1011

@@ -16,6 +17,13 @@ describe("api", () => {
1617
expect(result.success).toBe(true);
1718
});
1819

20+
it("getAllFixtures", async () => {
21+
const response = await getAllFixtures();
22+
const result = v.safeParse(v.array(FixtureSchema), response);
23+
24+
expect(result.success).toBe(true);
25+
});
26+
1927
it("getBootstrapStatic", async () => {
2028
const response = await getBootstrapStatic();
2129
const result = v.safeParse(BootstrapStaticSchema, response);

src/api.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ export const getEventFixtures = async ({
2323
};
2424

2525
/**
26-
* Fetches the current bootstrap-static endpoint data which
27-
* returns:
26+
* @returns All fixtures for every event.
27+
*/
28+
export const getAllFixtures = async (): Promise<Fixture[]> => {
29+
const response = await ofetch<Fixture[]>(`${BASE_URL}/fixtures/`);
30+
31+
return response;
32+
};
33+
34+
/**
35+
* Fetches the bootstrap-static endpoint data which returns:
2836
* - element_stats
2937
* - element_types
3038
* - elements

0 commit comments

Comments
 (0)