Skip to content

Commit

Permalink
CMR-10118: Fixes lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dmistry1 committed Oct 17, 2024
1 parent 8528286 commit 1432e10
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion serverless.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ provider:
CMR_LB_URL: "https://cmr.sit.earthdata.nasa.gov"
GRAPHQL_URL: "https://graphql.sit.earthdata.nasa.gov/api"
STAC_VERSION: "1.0.0"
PAGE_SIZE: 100
PAGE_SIZE: "100"

functions:
stac:
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/providerCatalog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ describe("GET /:provider", () => {
describe("when there are more results available", () => {
it("includes a 'next' link with the correct query parameters", async () => {
sandbox
.stub(Provider, "getProviders")
.resolves([null, [{ "provider-id": "TEST", "short-name": "TEST" }]]);
.stub(Provider, "getProviders")
.resolves([null, [{ "provider-id": "TEST", "short-name": "TEST" }]]);
const mockCollections = generateSTACCollections(100);
sandbox.stub(Collections, "getCollectionIds").resolves({
count: 100,
Expand All @@ -181,14 +181,14 @@ describe("GET /:provider", () => {
});

const { body: catalog } = await request(stacApp).get(`/stac/TEST`);
console.log("🚀 ~ it.only ~ catalog:", catalog)

console.log("🚀 ~ it.only ~ catalog:", catalog);
const nextLink = catalog.links.find((l: Link) => l.rel === "next");
expect(nextLink).to.exist;
expect(nextLink.rel).to.equal("next");
expect(nextLink.type).to.equal("application/json");
expect(nextLink.title).to.equal("Next page of results");

const nextUrl = new URL(nextLink.href);
expect(nextUrl.pathname).to.equal("/stac/TEST");
});
Expand All @@ -199,7 +199,7 @@ describe("GET /:provider", () => {
sandbox
.stub(Provider, "getProviders")
.resolves([null, [{ "provider-id": "TEST", "short-name": "TEST" }]]);

const mockCollections = generateSTACCollections(10);
sandbox.stub(Collections, "getCollectionIds").resolves({
count: 10,
Expand All @@ -211,7 +211,7 @@ describe("GET /:provider", () => {
});

const { body: catalog } = await request(stacApp).get("/stac/TEST");

const nextLink = catalog.links.find((l: Link) => l.rel === "next");
expect(nextLink).to.not.exist;
});
Expand Down
2 changes: 1 addition & 1 deletion src/domains/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const getAllCollectionIds = async (
cursor: string | null;
items: { id: string; title: string }[];
}> => {
params.limit = CMR_QUERY_MAX
params.limit = CMR_QUERY_MAX;

return await getCollectionIds(params, opts);
};
3 changes: 1 addition & 2 deletions src/domains/stac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export const paginateQuery = async (
opts: {
headers?: IncomingHttpHeaders;
},
handler: GraphQLHandler,
handler: GraphQLHandler
): Promise<GraphQLResults> => {
const paginatedParams = { ...params };

Expand Down Expand Up @@ -589,7 +589,6 @@ export const paginateQuery = async (
const { count, cursor, items } = data;

return { items: items, count, cursor };

} catch (err: unknown) {
if (
!(err instanceof Error) &&
Expand Down
13 changes: 8 additions & 5 deletions src/routes/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ const generateSelfLinks = (req: Request, nextCursor?: string | null): Links => {

links.push({
rel: "next",
href: `${stacRoot}${req.path}?${stringifyQuery(nextResultsQuery)}`,
href: `${stacRoot}${req.path}?${stringifyQuery(nextResultsQuery)}`,
type: "application/json",
title: "Next page of results"
title: "Next page of results",
});
}

return links
return links;
};

const providerCollections = async (
Expand All @@ -97,7 +97,10 @@ const providerCollections = async (

const cloudOnly = headers["cloud-stac"] === "true" ? { cloudHosted: true } : {};

const query2 = mergeMaybe({ provider: provider?.["provider-id"], cursor: query?.cursor }, { ...cloudOnly });
const query2 = mergeMaybe(
{ provider: provider?.["provider-id"], cursor: query?.cursor },
{ ...cloudOnly }
);

try {
const { items, cursor } = await getAllCollectionIds(query2, { headers });
Expand All @@ -120,7 +123,7 @@ export const providerCatalogHandler = async (req: Request, res: Response) => {
const { self } = stacContext(req);

const selfLinks = generateSelfLinks(req, cursor);

const childLinks = (collections ?? []).map(({ id, title }) => ({
rel: "child",
href: `${getBaseUrl(self)}/collections/${encodeURIComponent(id)}`,
Expand Down

0 comments on commit 1432e10

Please sign in to comment.