🔧 Added a hostname generator
This commit is contained in:
@@ -2,6 +2,7 @@ import axios from "axios";
|
||||
import { IFolderData, IExtractedComicBookCoverFile } from "threetwo-ui-typings";
|
||||
import {
|
||||
API_BASE_URI,
|
||||
COMICBOOKINFO_SERVICE_URI,
|
||||
IMPORT_SERVICE_BASE_URI,
|
||||
SOCKET_BASE_URI,
|
||||
} from "../constants/endpoints";
|
||||
@@ -74,7 +75,7 @@ export const fetchComicBookMetadata =
|
||||
);
|
||||
await axios
|
||||
.request({
|
||||
url: "http://localhost:8050/api/getComicCovers",
|
||||
url: `${API_BASE_URI}/getComicCovers`,
|
||||
method: "POST",
|
||||
data: {
|
||||
extractionOptions,
|
||||
@@ -190,7 +191,7 @@ export const fetchComicVineMatches = (searchPayload) => (dispatch) => {
|
||||
|
||||
axios
|
||||
.request({
|
||||
url: "http://localhost:3080/api/comicvine/fetchresource",
|
||||
url: `${COMICBOOKINFO_SERVICE_URI}/fetchresource`,
|
||||
method: "POST",
|
||||
data: {
|
||||
format: "json",
|
||||
|
||||
@@ -1,8 +1,38 @@
|
||||
export const COMICBOOKINFO_SERVICE_URI =
|
||||
`http://${process.env.DOCKER_HOST}/api/comicvine` ||
|
||||
"http://localhost:3080/api/comicvine";
|
||||
export const API_BASE_URI = "http://localhost:8050/api/";
|
||||
export const IMPORT_SERVICE_BASE_URI =
|
||||
`http://${process.env.DOCKER_HOST}/api/import` ||
|
||||
"http://localhost:3000/api/import";
|
||||
export const SOCKET_BASE_URI = "ws://localhost:8051";
|
||||
export const hostURIBuilder = (options: Record<string, string>): string => {
|
||||
return (
|
||||
options.protocol +
|
||||
"://" +
|
||||
options.host +
|
||||
":" +
|
||||
options.port +
|
||||
options.apiPath
|
||||
);
|
||||
};
|
||||
|
||||
export const COMICBOOKINFO_SERVICE_URI = hostURIBuilder({
|
||||
protocol: "http",
|
||||
host: process.env.DOCKER_HOST || "localhost",
|
||||
port: "3080",
|
||||
apiPath: "/api/comicvine",
|
||||
});
|
||||
|
||||
export const API_BASE_URI = hostURIBuilder({
|
||||
protocol: "http",
|
||||
host: process.env.DOCKER_HOST || "localhost",
|
||||
port: "8050",
|
||||
apiPath: "/api",
|
||||
});
|
||||
|
||||
export const IMPORT_SERVICE_BASE_URI = hostURIBuilder({
|
||||
protocol: "http",
|
||||
host: process.env.DOCKER_HOST || "localhost",
|
||||
port: "3000",
|
||||
apiPath: "/api/import",
|
||||
});
|
||||
|
||||
export const SOCKET_BASE_URI = hostURIBuilder({
|
||||
protocol: "ws",
|
||||
host: process.env.DOCKER_HOST || "localhost",
|
||||
port: "8051",
|
||||
apiPath: ``,
|
||||
});
|
||||
|
||||
@@ -8,9 +8,7 @@ import { success } from "react-notification-system-redux";
|
||||
const WebSocketContext = createContext(null);
|
||||
export const WebSocketProvider = ({ children }): ReactElement => {
|
||||
const dispatch = useDispatch();
|
||||
const socketHost =
|
||||
`http://${process.env.DOCKER_HOST}:8051` || SOCKET_BASE_URI;
|
||||
const socket: Socket = io(socketHost);
|
||||
const socket: Socket = io(SOCKET_BASE_URI);
|
||||
|
||||
socket.on("connect", () => {
|
||||
dispatch({
|
||||
|
||||
Reference in New Issue
Block a user