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

cleanup variables after reverse proxy launch #249

Merged
merged 4 commits into from
Dec 3, 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
7 changes: 2 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
APP_ENV=development # or qa or production

#IIIF
IIIF_URL=https://iiif.nypl.org

# Repo api
API_URL=https://api.repo.nypl.org # must be https
AUTH_TOKEN= # Get credentials from a parameter store or a teammate!
API_DEBUG=true # Optional, controls verbosity of api related log output
API_CACHE=false # Optional, controls whether or not api responses are cached

# Old DC url
DC_URL='' # OR https://qa-digitalcollections.nypl.org OR https://digitalcollections.nypl.org
# Base DC url
# DC_URL=''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in the ENVIRONMENTVARS.md file, so it should be removed here too. I don't see any references to it anymore.


# Feedback form
CLIENT_ID= # Available in parameter store
Expand Down
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

### Removed

- removed unneccessary variables post reverse proxy launch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "unnecessary environment variables"

- Removed new relic files from frontend (DR-3311)

### Added

- Added tests for API helpers (DR-3271)


### Updated

- Update thumbnail logic so thumbnails are never restricted (DR-3293)


## [0.2.4] 2024-11-26

### Updated
Expand Down
1 change: 0 additions & 1 deletion ENVIRONMENTVARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ These environment variables control how certain elements on the page render and
| Variable | Type | Value Example | Description |
| ---------------------------- | ------ | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `APP_ENV` | string | "development" | App environment key used to determine various environment-specific app settings. |
| `DC_URL` | string | "" or "https://qa-digitalcollections.nypl.org" or https://digitalcollections.nypl.org | The base URL of the DC url, either points locally or externally to legacy DC. |
| `API_URL` | string | "https://api.repo.nypl.org" or "https://qa.api.repo.nypl.org" | base url for Repo API calls. |
| `AUTH_TOKEN` | string | "" | Auth token for Repo API. |
| `ADOBE_EMBED_URL` | string | "" | Url endpoint used for Adobe Analytics event tracking. |
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ Example:
```
const appConfig = {
environment: process.env.APP_ENV || "development",
DC_URL: {
development: "https://qa-digitalcollections.nypl.org",
qa: "https://qa-digitalcollections.nypl.org",
production: "https://digitalcollections.nypl.org",
},
adobeEmbedUrl: {
development:
"https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-bf8436264b01-development.min.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import FeaturedContentComponent from "../featuredContent/featuredContent";
import { useEffect, useState } from "react";
import { DC_URL } from "@/src/config/constants";
import { Lane as DCLane } from "../lane/lane";
import LaneDataType from "@/src/types/Lane";
import LaneLoading from "../lane/laneLoading";
Expand All @@ -28,7 +27,7 @@ const HomePageMainContent = ({
<DCLane
key={0}
records={firstSwimLane.collections}
seeMoreLink={`${DC_URL}/collections/lane`}
seeMoreLink={`/collections/lane`}
avertrees marked this conversation as resolved.
Show resolved Hide resolved
laneName={firstSwimLane.name}
laneSlug={firstSwimLane.slug}
/>
Expand All @@ -37,7 +36,7 @@ const HomePageMainContent = ({
<DCLane
key={key}
records={lane.collections}
seeMoreLink={`${DC_URL}/collections/lane`}
seeMoreLink={`/collections/lane`}
laneName={lane.name}
laneSlug={lane.slug}
/>
Expand Down
11 changes: 5 additions & 6 deletions app/src/components/lane/lane.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fireEvent, render, screen, within } from "@testing-library/react";
import { mockCollectionLanes } from "__tests__/__mocks__/data/mockCollectionLanes";
import { DC_URL } from "@/src/config/constants";
import { Lane as DCLane } from "./lane";

describe("Lanes component renders with expected collection props", () => {
Expand All @@ -10,7 +9,7 @@ describe("Lanes component renders with expected collection props", () => {
{mockCollectionLanes.lanesWithNumItems.map((lane, key) => (
<DCLane
key={key}
seeMoreLink={`${DC_URL}/collections/lane`}
seeMoreLink={`/collections/lane`}
avertrees marked this conversation as resolved.
Show resolved Hide resolved
records={lane.collections}
laneName={lane.name}
laneSlug={lane.slug}
Expand All @@ -37,7 +36,7 @@ describe("Lanes component renders with expected collection props", () => {
{mockCollectionLanes.lanesWithNumItems.map((lane, key) => (
<DCLane
key={key}
seeMoreLink={`${DC_URL}/collections/lane`}
seeMoreLink={`/collections/lane`}
records={lane.collections}
laneName={lane.name}
laneSlug={lane.slug}
Expand Down Expand Up @@ -70,7 +69,7 @@ describe("Lanes component renders with expected collection props", () => {
{mockCollectionLanes.lanesWithNumItems.map((lane, key) => (
<DCLane
key={key}
seeMoreLink={`${DC_URL}/collections/lane`}
seeMoreLink={`/collections/lane`}
records={lane.collections}
laneName={lane.name}
laneSlug={lane.slug}
Expand All @@ -94,7 +93,7 @@ describe("Lanes component renders with expected collection props", () => {
{mockCollectionLanes.lanesWithNumItems.map((lane, key) => (
<DCLane
key={key}
seeMoreLink={`${DC_URL}/collections/lane`}
seeMoreLink={`/collections/lane`}
records={lane.collections}
laneName={lane.name}
laneSlug={lane.slug}
Expand All @@ -117,7 +116,7 @@ describe("Lanes component renders with expected collection props", () => {
{mockCollectionLanes.lanesWithNumItems.map((lane, key) => (
<DCLane
key={key}
seeMoreLink={`${DC_URL}/collections/lane`}
seeMoreLink={`/collections/lane`}
records={lane.collections}
laneName={lane.name}
laneSlug={lane.slug}
Expand Down
3 changes: 1 addition & 2 deletions app/src/components/lane/lane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from "@nypl/design-system-react-components";
import { Card as DCCard } from "../card/card";
import { SimpleGrid as DCSimpleGrid } from "../simpleGrid/simpleGrid";
import { DC_URL } from "@/src/config/constants";
import { headerBreakpoints } from "@/src/utils/breakpoints";
import { titleToDCParam } from "@/src/utils/utils";
import { ItemCardModel } from "@/src/models/itemCard";
Expand Down Expand Up @@ -54,7 +53,7 @@ export const Lane = ({
heading: `Items in the ${laneName}`,
headingId: `row-heading-${laneName}`,
seeMoreLinkId: `row-see-more-items-${laneName}`,
seeMoreLinkHref: `${DC_URL}/search/index?filters[divisionFullname_mtxt_s][]=${titleToDCParam(
seeMoreLinkHref: `/search/index?filters[divisionFullname_mtxt_s][]=${titleToDCParam(
laneName
)}`,
seeMoreAriaLabel: `See more items in ${laneName}`,
Expand Down
7 changes: 3 additions & 4 deletions app/src/components/navMenu/mobileNavMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import { render, fireEvent, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import MobileNavMenu from "./mobileNavMenu";
import { DC_URL } from "@/src/config/constants";

describe("Mobile nav menu component", () => {
it("renders mobile nav menu component", () => {
Expand All @@ -26,15 +25,15 @@ describe("Mobile nav menu component", () => {
fireEvent.click(screen.getByLabelText("Open Navigation"));
expect(screen.getByLabelText("Items")).toHaveAttribute(
"href",
`${DC_URL}/search/index?utf8=%E2%9C%93&keywords=`
`/search/index?utf8=%E2%9C%93&keywords=`
);
expect(screen.getByLabelText("Divisions")).toHaveAttribute(
"href",
`${DC_URL}/divisions`
`/divisions`
);
expect(screen.getByLabelText("Collections")).toHaveAttribute(
"href",
`${DC_URL}/collections`
`/collections`
);
expect(screen.getByLabelText("About")).toHaveAttribute("href", `/about`);
});
Expand Down
12 changes: 3 additions & 9 deletions app/src/components/navMenu/navMenu.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import appConfig from "../../../../appConfig";
import NavMenu from "./navMenu";
import { ENV_KEY } from "../../types/EnvironmentType";
import { DC_URL } from "../../config/constants";

describe("Nav menu component", () => {
it("renders nav menu component", () => {
Expand All @@ -19,15 +16,12 @@ describe("Nav menu component", () => {
const { getByLabelText } = render(<NavMenu render={1} />);
expect(getByLabelText("Items")).toHaveAttribute(
"href",
`${DC_URL}/search/index?utf8=%E2%9C%93&keywords=`
);
expect(getByLabelText("Divisions")).toHaveAttribute(
"href",
`${DC_URL}/divisions`
`/search/index?utf8=%E2%9C%93&keywords=`
);
expect(getByLabelText("Divisions")).toHaveAttribute("href", `/divisions`);
expect(getByLabelText("Collections")).toHaveAttribute(
"href",
`${DC_URL}/collections`
`/collections`
);
expect(getByLabelText("About")).toHaveAttribute("href", "/about");
});
Expand Down
3 changes: 1 addition & 2 deletions app/src/components/pages/divisionPage/divisionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
createAdobeAnalyticsPageName,
displayResults,
} from "../../../utils/utils";
import { DC_URL } from "@/src/config/constants";
import { Lane as DCLane } from "../../lane/lane";
import LaneLoading from "../../lane/laneLoading";

Expand Down Expand Up @@ -103,7 +102,7 @@ export default function DivisionPage({ data }: any) {
{isLoaded ? (
<DCLane
records={data.items}
seeMoreLink={`${DC_URL}/divisions`}
seeMoreLink={`/divisions`}
laneName={data.name}
/>
) : (
Expand Down
1 change: 0 additions & 1 deletion app/src/components/pages/divisionsPage/divisionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from "@nypl/design-system-react-components";
import PageLayout from "../../pageLayout/pageLayout";
import React, { useEffect, useState } from "react";
import { DC_URL } from "@/src/config/constants";
import { Lane as DCLane } from "../../lane/lane";
import LaneLoading from "../../lane/laneLoading";
import LaneDataType from "@/src/types/Lane";
Expand Down
5 changes: 2 additions & 3 deletions app/src/components/search/search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { render, fireEvent, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import Search from "./search";
import { useRouter } from "next/navigation";
import { DC_URL } from "../../config/constants";

jest.mock("next/navigation", () => ({
useRouter: jest.fn(),
Expand All @@ -27,7 +26,7 @@ describe("Search component", () => {
});
fireEvent.submit(getByLabelText("Search Digital Collections"));
expect(mockRouter.push).toHaveBeenCalledWith(
`${DC_URL}/search/index?keywords=test%20word`
`/search/index?keywords=test%20word`
);
});

Expand All @@ -45,7 +44,7 @@ describe("Search component", () => {
fireEvent.submit(screen.getByLabelText("Search Digital Collections"));

expect(mockRouter.push).toHaveBeenCalledWith(
`${DC_URL}/search/index?utf8=✓&filters%5Brights%5D=pd&keywords=test%20words`
`/search/index?utf8=✓&filters%5Brights%5D=pd&keywords=test%20words`
);
});
});
2 changes: 0 additions & 2 deletions app/src/components/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Box, SearchBar } from "@nypl/design-system-react-components";
import { useRouter } from "next/navigation";
import PublicDomainFilter from "../publicDomainFilter/publicDomainFilter";
import { headerBreakpoints } from "../../utils/breakpoints";
import { DC_URL } from "../../config/constants";

const Search = () => {
const router = useRouter();
Expand All @@ -15,7 +14,6 @@ const Search = () => {
const handleSubmit = (event) => {
event.preventDefault();
const searchUrl =
DC_URL +
`/search/index?` +
(publicDomainOnly ? `utf8=✓&filters%5Brights%5D=pd&` : ``) +
`keywords=${encodeURIComponent(keywords)}`;
Expand Down
1 change: 0 additions & 1 deletion app/src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import appConfig from "../../../appConfig";

export const BASE_URL = "/";
export const SITE_NAME = "NYPL Digital Collections";
export const DC_URL = appConfig.DC_URL[appConfig.environment as ENV_KEY];

// String used to namespace Digital Collection events in Adobe Analytics
export const ADOBE_ANALYTICS_SITE_SECTION = "Digital Collections";
Expand Down
6 changes: 2 additions & 4 deletions app/src/data/dcNavLinks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { DC_URL } from "../config/constants";

export const dcNavLinks = [
{
href: `${DC_URL}/search/index?utf8=%E2%9C%93&keywords=`,
href: `/search/index?utf8=%E2%9C%93&keywords=`,
text: "Items",
},
{
href: `${DC_URL}/collections`,
href: `/collections`,
text: "Collections",
},
{
Expand Down
3 changes: 1 addition & 2 deletions app/src/utils/apiHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { imageURL, addCommas } from "./utils";
import appConfig from "../../../appConfig";
import defaultFeaturedItems from "../data/defaultFeaturedItemData";
import { CARDS_PER_PAGE } from "../config/constants";
import { DC_URL } from "../config/constants";
import { fetchApi } from "./fetchApi";

export const getHomePageData = async () => {
Expand Down Expand Up @@ -54,7 +53,7 @@ export const getFeaturedItemData = async () => {
),
uuid: featuredImageData.uuid,
title: featuredImageData.title,
href: `${DC_URL}/items/${featuredImageData.uuid}`,
href: `/items/${featuredImageData.uuid}`,
};
const newResponse = {
featuredItem: featuredItemObject,
Expand Down
6 changes: 1 addition & 5 deletions app/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {
ADOBE_ANALYTICS_SITE_SECTION,
ADOBE_ANALYTICS_DC_PREFIX,
} from "../config/constants";
import { ENV_KEY } from "../types/EnvironmentType";
import appConfig from "../../../appConfig";
import CollectionDataType from "@/src/types/CollectionDataType";
import ItemDataType from "@/src/types/ItemDataType";

Expand All @@ -23,9 +21,7 @@ export const imageURL = (
size = "!1600,1600",
rotation = "0"
) => {
return `${
appConfig.IIIF_URL[appConfig.environment as ENV_KEY]
}/iiif/2/${imageId}/${region}/${size}/${rotation}/default.jpg`;
return `https://iiif.nypl.org/iiif/2/${imageId}/${region}/${size}/${rotation}/default.jpg`;
};

export function addCommas(number: string) {
Expand Down
10 changes: 0 additions & 10 deletions appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
const appConfig = {
environment: process.env.APP_ENV || "development",
DC_URL: {
development: "",
qa: "",
production: "",
},
IIIF_URL: {
development: "https://iiif.nypl.org",
qa: "https://iiif.nypl.org",
production: "https://iiif.nypl.org",
},
adobeEmbedUrl: {
development:
"https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-bf8436264b01-development.min.js",
Expand Down
2 changes: 0 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const nextConfig = {
},
reactStrictMode: false,
env: {
DC_URL: process.env.DC_URL,
IIIF_URL: process.env.IIIF_URL,
ADOBE_EMBED_URL: process.env.ADOBE_EMBED_URL,
APP_ENV: process.env.APP_ENV,
NEW_RELIC_LICENSE_KEY: process.env.NEW_RELIC_LICENSE_KEY,
Expand Down
4 changes: 1 addition & 3 deletions public/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

### Removed

- removed unneccessary variables post reverse proxy launch
- Removed new relic files from frontend (DR-3311)

### Added

- Added tests for API helpers (DR-3271)


### Updated

- Update thumbnail logic so thumbnails are never restricted (DR-3293)


## [0.2.4] 2024-11-26

### Updated
Expand Down
Loading