Skip to content

Commit

Permalink
Merge pull request #570 from NYPL/SFR-2418/plural-noun-endpoints
Browse files Browse the repository at this point in the history
SFR-2418: Update api endpoints to plural noun
  • Loading branch information
jackiequach authored Dec 23, 2024
2 parents cf9a9f9 + 9388d5c commit 4434b33
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
8 changes: 4 additions & 4 deletions config/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion mocks/mockEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
4 changes: 2 additions & 2 deletions src/__tests__/fixtures/CollectionFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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",
},
Expand Down
5 changes: 4 additions & 1 deletion src/lib/api/CollectionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Error from "./_error";
export async function getServerSideProps() {
// Fetch all collections
const collectionResult: CollectionResult = await collectionFetcher({
identifier: "list",
perPage: 8,
});

Expand Down
2 changes: 1 addition & 1 deletion src/types/CollectionQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ApiCollectionQuery = {
};

export type CollectionQuery = {
identifier: string;
identifier?: string;
page?: number;
perPage?: number;
sort?: string;
Expand Down

0 comments on commit 4434b33

Please sign in to comment.