diff --git a/src/client/actions/airdcpp.actions.tsx b/src/client/actions/airdcpp.actions.tsx index 58a24a3..f5cfeea 100644 --- a/src/client/actions/airdcpp.actions.tsx +++ b/src/client/actions/airdcpp.actions.tsx @@ -5,6 +5,7 @@ import { PriorityEnum, SearchResponse, } from "threetwo-ui-typings"; +import { IMPORT_SERVICE_BASE_URI } from "../constants/endpoints"; import { AIRDCPP_SEARCH_RESULTS_ADDED, AIRDCPP_SEARCH_RESULTS_UPDATED, @@ -129,7 +130,7 @@ export const downloadAirDCPPItem = if (!isNil(downloadResult)) { bundleDBImportResult = await axios({ method: "POST", - url: "http://localhost:3000/api/import/applyAirDCPPDownloadMetadata", + url: `${IMPORT_SERVICE_BASE_URI}/applyAirDCPPDownloadMetadata`, headers: { "Content-Type": "application/json; charset=utf-8", }, @@ -187,7 +188,7 @@ export const getBundlesForComic = } const comicObject = await axios({ method: "POST", - url: "http://localhost:3000/api/import/getComicBookById", + url: `${IMPORT_SERVICE_BASE_URI}/getComicBookById`, headers: { "Content-Type": "application/json; charset=utf-8", }, diff --git a/src/client/actions/comicinfo.actions.tsx b/src/client/actions/comicinfo.actions.tsx index 21526c8..702edd3 100644 --- a/src/client/actions/comicinfo.actions.tsx +++ b/src/client/actions/comicinfo.actions.tsx @@ -12,7 +12,10 @@ import { IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS, IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_CALL_IN_PROGRESS, } from "../constants/action-types"; -import { COMICBOOKINFO_SERVICE_URI } from "../constants/endpoints"; +import { + COMICBOOKINFO_SERVICE_URI, + IMPORT_SERVICE_BASE_URI, +} from "../constants/endpoints"; const http = rateLimiter(axios.create(), { maxRequests: 1, @@ -67,7 +70,7 @@ export const getComicBookDetailById = IMS_inProgress: true, }); const result = await axios.request({ - url: `http://localhost:3000/api/import/getComicBookById`, + url: `${IMPORT_SERVICE_BASE_URI}/getComicBookById`, method: "POST", data: { id: comicBookObjectId, @@ -87,7 +90,7 @@ export const applyComicVineMatch = IMS_inProgress: true, }); const result = await axios.request({ - url: "http://localhost:3000/api/import/applyComicVineMetadata", + url: `${IMPORT_SERVICE_BASE_URI}/applyComicVineMetadata`, method: "POST", data: { match, @@ -109,7 +112,7 @@ export const extractComicArchive = }); const extractedComicBookArchive = await axios({ method: "POST", - url: "http://localhost:3000/api/import/unrarArchive", + url: `${IMPORT_SERVICE_BASE_URI}/unrarArchive`, headers: { "Content-Type": "application/json; charset=utf-8", }, @@ -122,9 +125,9 @@ export const extractComicArchive = const foo = page.path.split("/"); const folderName = foo[foo.length - 1]; const imagePath = encodeURI( - "http://localhost:3000/userdata/expanded/" + + `${IMPORT_SERVICE_BASE_URI}/userdata/expanded/` + folderName + - "/" + + `/` + page.name + page.extension, ); diff --git a/src/client/components/Card.tsx b/src/client/components/Card.tsx index 80f7935..8e82195 100644 --- a/src/client/components/Card.tsx +++ b/src/client/components/Card.tsx @@ -6,6 +6,7 @@ import { } from "../shared/utils/formatting.utils"; import { isUndefined, isEmpty, isNil } from "lodash"; import { Link } from "react-router-dom"; +import { IMPORT_SERVICE_HOST } from "../constants/endpoints"; import ellipsize from "ellipsize"; interface IProps { @@ -26,7 +27,7 @@ class Card extends React.Component { metadata: IExtractedComicBookCoverFile, ): JSX.Element => { const encodedFilePath = encodeURI( - "http://localhost:3000" + removeLeadingPeriod(metadata.path), + `${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(metadata.path), ); const filePath = escapePoundSymbol(encodedFilePath); return ( diff --git a/src/client/components/ComicDetail.tsx b/src/client/components/ComicDetail.tsx index 9797457..bd7fbc8 100644 --- a/src/client/components/ComicDetail.tsx +++ b/src/client/components/ComicDetail.tsx @@ -29,6 +29,7 @@ import { escapePoundSymbol, } from "../shared/utils/formatting.utils"; import Sticky from "react-stickynode"; +import { IMPORT_SERVICE_HOST } from "../constants/endpoints"; type ComicDetailProps = {}; /** @@ -465,7 +466,7 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => { let comicBookTitle = ""; if (!isNil(comicBookDetailData.rawFileDetails)) { const encodedFilePath = encodeURI( - "http://localhost:3000" + + `${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(comicBookDetailData.rawFileDetails.cover.filePath), ); imagePath = escapePoundSymbol(encodedFilePath); diff --git a/src/client/components/Library.tsx b/src/client/components/Library.tsx index 221ed67..82a3dd0 100644 --- a/src/client/components/Library.tsx +++ b/src/client/components/Library.tsx @@ -11,6 +11,7 @@ import ellipsize from "ellipsize"; import { useDispatch, useSelector } from "react-redux"; import { getComicBooks } from "../actions/fileops.actions"; import { isNil } from "lodash"; +import { IMPORT_SERVICE_HOST } from "../constants/endpoints"; interface IComicBookLibraryProps { matches?: unknown; @@ -38,7 +39,7 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => { const RawFileDetails = ({ value }) => { if (!isNil(value.path)) { const encodedFilePath = encodeURI( - "http://localhost:3000" + removeLeadingPeriod(value.cover.filePath), + `${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(value.cover.filePath), ); const filePath = escapePoundSymbol(encodedFilePath); return ( diff --git a/src/client/components/LibraryGrid.tsx b/src/client/components/LibraryGrid.tsx index 06b84ba..42a61df 100644 --- a/src/client/components/LibraryGrid.tsx +++ b/src/client/components/LibraryGrid.tsx @@ -15,6 +15,7 @@ import Masonry from "react-masonry-css"; import Card from "./Carda"; import { detectIssueTypes } from "../shared/utils/tradepaperback.utils"; import { Link } from "react-router-dom"; +import { IMPORT_SERVICE_HOST } from "../constants/endpoints"; interface ILibraryGridProps {} @@ -47,7 +48,7 @@ export const LibraryGrid = (libraryGridProps: ILibraryGridProps) => { let comicName = ""; if (!isNil(rawFileDetails)) { const encodedFilePath = encodeURI( - "http://localhost:3000" + + `${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(rawFileDetails.cover.filePath), ); imagePath = escapePoundSymbol(encodedFilePath); diff --git a/src/client/components/RecentlyImported.tsx b/src/client/components/RecentlyImported.tsx index e4cbbfe..d6b606b 100644 --- a/src/client/components/RecentlyImported.tsx +++ b/src/client/components/RecentlyImported.tsx @@ -9,6 +9,7 @@ import { import { isNil, isUndefined, map } from "lodash"; import { detectIssueTypes } from "../shared/utils/tradepaperback.utils"; import Masonry from "react-masonry-css"; +import { IMPORT_SERVICE_HOST } from "../constants/endpoints"; type RecentlyImportedProps = { comicBookCovers: any; @@ -40,7 +41,7 @@ export const RecentlyImported = ({ let comicName = ""; if (!isNil(rawFileDetails)) { const encodedFilePath = encodeURI( - "http://localhost:3000" + + `${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(rawFileDetails.cover.filePath), ); imagePath = escapePoundSymbol(encodedFilePath); diff --git a/src/client/constants/endpoints.ts b/src/client/constants/endpoints.ts index 541b86b..4b5b13a 100644 --- a/src/client/constants/endpoints.ts +++ b/src/client/constants/endpoints.ts @@ -23,6 +23,12 @@ export const API_BASE_URI = hostURIBuilder({ apiPath: "/api", }); +export const IMPORT_SERVICE_HOST = hostURIBuilder({ + protocol: "http", + host: process.env.DOCKER_HOST || "localhost", + port: "3000", + apiPath: ``, +}); export const IMPORT_SERVICE_BASE_URI = hostURIBuilder({ protocol: "http", host: process.env.DOCKER_HOST || "localhost",