Spaces:
Sleeping
Sleeping
Download src/modules/shopify/presentation/http/controllers/ShopifySyncController.ts from fouadkhalid123/asd: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/modules/shopify/presentation/http/controllers/ShopifySyncController.ts
- Command line
-
hf download hf://spaces/fouadkhalid123/asd/src/modules/shopify/presentation/http/controllers/ShopifySyncController.ts
-
curl -L -o ShopifySyncController.ts https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/modules/shopify/presentation/http/controllers/ShopifySyncController.ts
1.28 kB
| import { Request, Response } from "express"; | |
| import { TriggerSyncUseCase } from "../../../application/useCases/sync/TriggerSyncUseCase"; | |
| import { PgSyncJobRepository } from "../../../infrastructure/postgres/repositories/PgSyncJobRepository"; | |
| import { InMemoryEventPublisher } from "../../../application/ports/IEventPublisher"; | |
| export const ShopifySyncController = async (req: Request, res: Response): Promise<void> => { | |
| // ββ Shared instances β created inside function to ensure DB connection is ready ββ | |
| const syncJobRepository = new PgSyncJobRepository(); | |
| const eventPublisher = new InMemoryEventPublisher(); | |
| const tenantContext = req.tenantContext; | |
| if (!tenantContext) { | |
| // Should never happen β TenantMiddleware runs before this | |
| res.status(401).json({ error: { code: "UNAUTHORIZED", message: "Tenant context missing" } }); | |
| return; | |
| } | |
| const action = (req.body?.action as "full" | "retry_failed") || "full"; | |
| const useCase = new TriggerSyncUseCase(tenantContext, syncJobRepository, eventPublisher); | |
| const result = await useCase.execute({ | |
| tenantId: tenantContext.tenantId, | |
| action, | |
| }); | |
| res.status(202).json(result); | |
| // Errors bubble to GlobalErrorHandler β no try/catch here | |
| }; | |