42 lines
1.6 KiB
TypeScript
Executable file
42 lines
1.6 KiB
TypeScript
Executable file
import '@/src/lib/notif-job'
|
|
import { initializeAllStores } from '@/src/stores/store-initializer'
|
|
import { initializeUserNegativityStore } from '@/src/stores/user-negativity-store'
|
|
import { startOrderHandler, startCancellationHandler, publishOrder } from '@/src/lib/post-order-handler'
|
|
import { deleteOrders } from '@/src/lib/delete-orders'
|
|
import { createAllCacheFiles } from '@/src/lib/cloud_cache'
|
|
import { verifyProductsAvailabilityBySchedule } from './manage-scheduled-availability'
|
|
|
|
/**
|
|
* Initialize all application services
|
|
* This function handles initialization of:
|
|
* - Role Manager (fetches and caches all roles)
|
|
* - Const Store (syncs constants from DB to Redis)
|
|
* - Post Order Handler (Redis Pub/Sub subscriber)
|
|
* - Cancellation Handler (Redis Pub/Sub subscriber for order cancellations)
|
|
* - User Negativity Store (caches user negativity scores in Redis)
|
|
* - Other services can be added here in the future
|
|
*/
|
|
export const initFunc = async (): Promise<void> => {
|
|
try {
|
|
console.log('Starting application initialization...');
|
|
|
|
await verifyProductsAvailabilityBySchedule(false);
|
|
await Promise.all([
|
|
initializeAllStores(),
|
|
initializeUserNegativityStore(),
|
|
startOrderHandler(),
|
|
startCancellationHandler(),
|
|
]);
|
|
|
|
// Create all cache files after stores are initialized
|
|
await createAllCacheFiles();
|
|
console.log('Cache files created successfully');
|
|
|
|
console.log('Application initialization completed successfully');
|
|
} catch (error) {
|
|
console.error('Application initialization failed:', error);
|
|
throw error;
|
|
}
|
|
};
|
|
|
|
export default initFunc;
|