🤼 groundwork for automatcher

This commit is contained in:
2021-06-01 07:40:31 -07:00
parent 5effa08342
commit 68194898d4
5 changed files with 17 additions and 61 deletions

View File

@@ -1,8 +1,14 @@
import axios from "axios";
import { IFolderData } from "../../server/interfaces/folder.interface";
import { API_BASE_URI } from "../constants/endpoints";
import {
IFolderData,
IExtractedComicBookCoverFile,
} from "../../server/interfaces/folder.interface";
import { API_BASE_URI, SOCKET_BASE_URI } from "../constants/endpoints";
import { io } from "socket.io-client";
import { IMS_SOCKET_DATA_FETCHED } from "../constants/action-types";
import {
IMS_SOCKET_DATA_FETCHED,
IMS_SOCKET_CONNECTION_CONNECTED,
} from "../constants/action-types";
export async function walkFolder(path: string): Promise<Array<IFolderData>> {
return axios
@@ -33,12 +39,15 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
};
const walkedFolders = await walkFolder("./comics");
const socket = io("ws://localhost:3000/", {
const socket = io(SOCKET_BASE_URI, {
reconnectionDelayMax: 10000,
});
socket.on("connect", () => {
console.log(`connect ${socket.id}`);
dispatch({
type: IMS_SOCKET_CONNECTION_CONNECTED,
});
});
socket.on("disconnect", () => {
@@ -53,7 +62,7 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
opts: { garam: "pasha" },
});
socket.on("comicBookCoverMetadata", (data) => {
socket.on("comicBookCoverMetadata", (data: IExtractedComicBookCoverFile) => {
dispatch({
type: IMS_SOCKET_DATA_FETCHED,
data,
@@ -61,5 +70,3 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
});
});
};
export const validate = (object) => {};