move AI flyer processing to background BullMQ jobs using redis for storage
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 6m21s

This commit is contained in:
2025-12-02 14:31:01 -08:00
parent a8f650d513
commit 80e2222d20
18 changed files with 1244 additions and 200 deletions

View File

@@ -197,6 +197,14 @@ export const checkDbPoolHealth = async (): Promise<Response> => {
return fetch(`${API_BASE_URL}/health/db-pool`);
};
/**
* Checks the backend's Redis connection health.
* @returns A promise that resolves to an object with success status and a message.
*/
export const checkRedisHealth = async (): Promise<Response> => {
return fetch(`${API_BASE_URL}/health/redis`);
};
/**
* Checks the status of the application process managed by PM2.
* This is intended for development and diagnostic purposes.
@@ -233,26 +241,6 @@ export const fetchCategories = async (): Promise<Response> => {
// --- Flyer Processing API Function ---
export const processFlyerFile = async (
flyerImage: File,
checksum: string,
originalFileName: string,
extractedData: { store_name: string; valid_from: string | null; valid_to: string | null; items: Omit<FlyerItem, 'flyer_item_id' | 'flyer_id' | 'created_at'>[]; store_address: string | null },
tokenOverride?: string
): Promise<Response> => {
const formData = new FormData();
formData.append('flyerImage', flyerImage);
// We send the structured data as a JSON string in a separate form field.
const dataPayload = { checksum, originalFileName, extractedData };
formData.append('data', JSON.stringify(dataPayload));
return apiFetchWithAuth(`/ai/flyers/process`, {
method: 'POST',
body: formData,
}, tokenOverride);
};
// --- Flyer Item API Functions ---
export const fetchFlyerItems = async (flyerId: number): Promise<Response> => {