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