🍬 Removed hardcoded reference to import-service

TODO: Remove the repetitive use of thumbnail generating logic
This commit is contained in:
2021-10-21 12:03:58 -07:00
parent 419962c756
commit 116cbf2a62
8 changed files with 28 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ import {
PriorityEnum, PriorityEnum,
SearchResponse, SearchResponse,
} from "threetwo-ui-typings"; } from "threetwo-ui-typings";
import { IMPORT_SERVICE_BASE_URI } from "../constants/endpoints";
import { import {
AIRDCPP_SEARCH_RESULTS_ADDED, AIRDCPP_SEARCH_RESULTS_ADDED,
AIRDCPP_SEARCH_RESULTS_UPDATED, AIRDCPP_SEARCH_RESULTS_UPDATED,
@@ -129,7 +130,7 @@ export const downloadAirDCPPItem =
if (!isNil(downloadResult)) { if (!isNil(downloadResult)) {
bundleDBImportResult = await axios({ bundleDBImportResult = await axios({
method: "POST", method: "POST",
url: "http://localhost:3000/api/import/applyAirDCPPDownloadMetadata", url: `${IMPORT_SERVICE_BASE_URI}/applyAirDCPPDownloadMetadata`,
headers: { headers: {
"Content-Type": "application/json; charset=utf-8", "Content-Type": "application/json; charset=utf-8",
}, },
@@ -187,7 +188,7 @@ export const getBundlesForComic =
} }
const comicObject = await axios({ const comicObject = await axios({
method: "POST", method: "POST",
url: "http://localhost:3000/api/import/getComicBookById", url: `${IMPORT_SERVICE_BASE_URI}/getComicBookById`,
headers: { headers: {
"Content-Type": "application/json; charset=utf-8", "Content-Type": "application/json; charset=utf-8",
}, },

View File

@@ -12,7 +12,10 @@ import {
IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS, IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS,
IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_CALL_IN_PROGRESS, IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_CALL_IN_PROGRESS,
} from "../constants/action-types"; } 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(), { const http = rateLimiter(axios.create(), {
maxRequests: 1, maxRequests: 1,
@@ -67,7 +70,7 @@ export const getComicBookDetailById =
IMS_inProgress: true, IMS_inProgress: true,
}); });
const result = await axios.request({ const result = await axios.request({
url: `http://localhost:3000/api/import/getComicBookById`, url: `${IMPORT_SERVICE_BASE_URI}/getComicBookById`,
method: "POST", method: "POST",
data: { data: {
id: comicBookObjectId, id: comicBookObjectId,
@@ -87,7 +90,7 @@ export const applyComicVineMatch =
IMS_inProgress: true, IMS_inProgress: true,
}); });
const result = await axios.request({ const result = await axios.request({
url: "http://localhost:3000/api/import/applyComicVineMetadata", url: `${IMPORT_SERVICE_BASE_URI}/applyComicVineMetadata`,
method: "POST", method: "POST",
data: { data: {
match, match,
@@ -109,7 +112,7 @@ export const extractComicArchive =
}); });
const extractedComicBookArchive = await axios({ const extractedComicBookArchive = await axios({
method: "POST", method: "POST",
url: "http://localhost:3000/api/import/unrarArchive", url: `${IMPORT_SERVICE_BASE_URI}/unrarArchive`,
headers: { headers: {
"Content-Type": "application/json; charset=utf-8", "Content-Type": "application/json; charset=utf-8",
}, },
@@ -122,9 +125,9 @@ export const extractComicArchive =
const foo = page.path.split("/"); const foo = page.path.split("/");
const folderName = foo[foo.length - 1]; const folderName = foo[foo.length - 1];
const imagePath = encodeURI( const imagePath = encodeURI(
"http://localhost:3000/userdata/expanded/" + `${IMPORT_SERVICE_BASE_URI}/userdata/expanded/` +
folderName + folderName +
"/" + `/` +
page.name + page.name +
page.extension, page.extension,
); );

View File

@@ -6,6 +6,7 @@ import {
} from "../shared/utils/formatting.utils"; } from "../shared/utils/formatting.utils";
import { isUndefined, isEmpty, isNil } from "lodash"; import { isUndefined, isEmpty, isNil } from "lodash";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { IMPORT_SERVICE_HOST } from "../constants/endpoints";
import ellipsize from "ellipsize"; import ellipsize from "ellipsize";
interface IProps { interface IProps {
@@ -26,7 +27,7 @@ class Card extends React.Component<IProps, IState> {
metadata: IExtractedComicBookCoverFile, metadata: IExtractedComicBookCoverFile,
): JSX.Element => { ): JSX.Element => {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
"http://localhost:3000" + removeLeadingPeriod(metadata.path), `${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(metadata.path),
); );
const filePath = escapePoundSymbol(encodedFilePath); const filePath = escapePoundSymbol(encodedFilePath);
return ( return (

View File

@@ -29,6 +29,7 @@ import {
escapePoundSymbol, escapePoundSymbol,
} from "../shared/utils/formatting.utils"; } from "../shared/utils/formatting.utils";
import Sticky from "react-stickynode"; import Sticky from "react-stickynode";
import { IMPORT_SERVICE_HOST } from "../constants/endpoints";
type ComicDetailProps = {}; type ComicDetailProps = {};
/** /**
@@ -465,7 +466,7 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => {
let comicBookTitle = ""; let comicBookTitle = "";
if (!isNil(comicBookDetailData.rawFileDetails)) { if (!isNil(comicBookDetailData.rawFileDetails)) {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
"http://localhost:3000" + `${IMPORT_SERVICE_HOST}` +
removeLeadingPeriod(comicBookDetailData.rawFileDetails.cover.filePath), removeLeadingPeriod(comicBookDetailData.rawFileDetails.cover.filePath),
); );
imagePath = escapePoundSymbol(encodedFilePath); imagePath = escapePoundSymbol(encodedFilePath);

View File

@@ -11,6 +11,7 @@ import ellipsize from "ellipsize";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { getComicBooks } from "../actions/fileops.actions"; import { getComicBooks } from "../actions/fileops.actions";
import { isNil } from "lodash"; import { isNil } from "lodash";
import { IMPORT_SERVICE_HOST } from "../constants/endpoints";
interface IComicBookLibraryProps { interface IComicBookLibraryProps {
matches?: unknown; matches?: unknown;
@@ -38,7 +39,7 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => {
const RawFileDetails = ({ value }) => { const RawFileDetails = ({ value }) => {
if (!isNil(value.path)) { if (!isNil(value.path)) {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
"http://localhost:3000" + removeLeadingPeriod(value.cover.filePath), `${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(value.cover.filePath),
); );
const filePath = escapePoundSymbol(encodedFilePath); const filePath = escapePoundSymbol(encodedFilePath);
return ( return (

View File

@@ -15,6 +15,7 @@ import Masonry from "react-masonry-css";
import Card from "./Carda"; import Card from "./Carda";
import { detectIssueTypes } from "../shared/utils/tradepaperback.utils"; import { detectIssueTypes } from "../shared/utils/tradepaperback.utils";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { IMPORT_SERVICE_HOST } from "../constants/endpoints";
interface ILibraryGridProps {} interface ILibraryGridProps {}
@@ -47,7 +48,7 @@ export const LibraryGrid = (libraryGridProps: ILibraryGridProps) => {
let comicName = ""; let comicName = "";
if (!isNil(rawFileDetails)) { if (!isNil(rawFileDetails)) {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
"http://localhost:3000" + `${IMPORT_SERVICE_HOST}` +
removeLeadingPeriod(rawFileDetails.cover.filePath), removeLeadingPeriod(rawFileDetails.cover.filePath),
); );
imagePath = escapePoundSymbol(encodedFilePath); imagePath = escapePoundSymbol(encodedFilePath);

View File

@@ -9,6 +9,7 @@ import {
import { isNil, isUndefined, map } from "lodash"; import { isNil, isUndefined, map } from "lodash";
import { detectIssueTypes } from "../shared/utils/tradepaperback.utils"; import { detectIssueTypes } from "../shared/utils/tradepaperback.utils";
import Masonry from "react-masonry-css"; import Masonry from "react-masonry-css";
import { IMPORT_SERVICE_HOST } from "../constants/endpoints";
type RecentlyImportedProps = { type RecentlyImportedProps = {
comicBookCovers: any; comicBookCovers: any;
@@ -40,7 +41,7 @@ export const RecentlyImported = ({
let comicName = ""; let comicName = "";
if (!isNil(rawFileDetails)) { if (!isNil(rawFileDetails)) {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
"http://localhost:3000" + `${IMPORT_SERVICE_HOST}` +
removeLeadingPeriod(rawFileDetails.cover.filePath), removeLeadingPeriod(rawFileDetails.cover.filePath),
); );
imagePath = escapePoundSymbol(encodedFilePath); imagePath = escapePoundSymbol(encodedFilePath);

View File

@@ -23,6 +23,12 @@ export const API_BASE_URI = hostURIBuilder({
apiPath: "/api", 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({ export const IMPORT_SERVICE_BASE_URI = hostURIBuilder({
protocol: "http", protocol: "http",
host: process.env.DOCKER_HOST || "localhost", host: process.env.DOCKER_HOST || "localhost",