Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFR-2418: Update api endpoints to plural noun #570

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading