From 715717afc46f2e0f69b5e3ef258576793b27c533 Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Thu, 19 Dec 2024 14:45:46 -0500 Subject: [PATCH 1/2] update api endpoints to plural noun --- CHANGELOG.md | 1 + config/appConfig.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7755440..8179e803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Remove Kristo, Jiayong, and Olivia and add Kyle as codeowners - Deploy to new Terraform ECS cluster in production - Deploy only to the new Terraform ECS clusters +- Update API endpoints to plural nouns ## [0.18.9] diff --git a/config/appConfig.ts b/config/appConfig.ts index 7dfdeb75..603fa0a3 100644 --- a/config/appConfig.ts +++ b/config/appConfig.ts @@ -13,11 +13,11 @@ const appConfig = { production: "http://drb-api-qa.nypl.org", }, searchPath: "/search", - recordPath: "/work", - editionPath: "/edition", - readPath: "/link", + recordPath: "/works", + editionPath: "/editions", + readPath: "/links", languagesPath: "/utils/languages", - collectionPath: "/collection", + collectionPath: "/collections", }, booksCount: { apiUrl: "/utils/counts", From 9388d5ca51eed66ec62813952e2ab629bb4c3aba Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Thu, 19 Dec 2024 15:42:11 -0500 Subject: [PATCH 2/2] update collection list call --- mocks/mockEnv.ts | 2 +- src/__tests__/fixtures/CollectionFixture.ts | 4 ++-- src/lib/api/CollectionApi.ts | 5 ++++- src/pages/index.tsx | 1 - src/types/CollectionQuery.ts | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mocks/mockEnv.ts b/mocks/mockEnv.ts index 34373aa8..451550b0 100644 --- a/mocks/mockEnv.ts +++ b/mocks/mockEnv.ts @@ -5,5 +5,5 @@ export const LIMITED_ACCESS_EDITION_PATH = "/edition/6977884"; export const WORK_PATH = "/work/5950e6df-9d99-42fe-8924-1116166a2acb"; export const DOWNLOAD_PATH = "/test-download-pdf"; export const HOME_PATH = "/"; -export const COLLECTION_LIST_PATH = "/collection/list"; +export const COLLECTION_LIST_PATH = "/collections"; export const INVALID_COLLECTION_PATH = "/collection/invalid-collection"; diff --git a/src/__tests__/fixtures/CollectionFixture.ts b/src/__tests__/fixtures/CollectionFixture.ts index a29948df..077af333 100644 --- a/src/__tests__/fixtures/CollectionFixture.ts +++ b/src/__tests__/fixtures/CollectionFixture.ts @@ -188,7 +188,7 @@ export const oneCollectionListData: Opds2Feed = { ], links: [ { - href: "/collection/list?page=1", + href: "/collections?page=1", rel: ["self", "first", "previous", "next", "last"], type: "application/opds+json", }, @@ -1721,7 +1721,7 @@ export const collectionListData: CollectionResult = { ], links: [ { - href: "/collection/list?page=1", + href: "/collections?page=1", rel: ["self", "first", "previous", "next", "last"], type: "application/opds+json", }, diff --git a/src/lib/api/CollectionApi.ts b/src/lib/api/CollectionApi.ts index 190bda48..255bdcd5 100644 --- a/src/lib/api/CollectionApi.ts +++ b/src/lib/api/CollectionApi.ts @@ -15,7 +15,10 @@ const collectionUrl = apiUrl + collectionPath; export const collectionFetcher = async (query: CollectionQuery) => { const collectionApiQuery = toApiCollectionQuery(query); - const url = new URL(collectionUrl + "/" + query.identifier); + const urlWithIdentifier = query.identifier + ? collectionUrl + "/" + query.identifier + : collectionUrl; + const url = new URL(urlWithIdentifier); url.search = new URLSearchParams( toLocationQuery(collectionApiQuery) ).toString(); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 85c6e37c..e5e833ec 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -9,7 +9,6 @@ import Error from "./_error"; export async function getServerSideProps() { // Fetch all collections const collectionResult: CollectionResult = await collectionFetcher({ - identifier: "list", perPage: 8, }); diff --git a/src/types/CollectionQuery.ts b/src/types/CollectionQuery.ts index 7ec689f9..2cb32fec 100644 --- a/src/types/CollectionQuery.ts +++ b/src/types/CollectionQuery.ts @@ -6,7 +6,7 @@ export type ApiCollectionQuery = { }; export type CollectionQuery = { - identifier: string; + identifier?: string; page?: number; perPage?: number; sort?: string;