- Marked tasks in `TODO.md` as completed for moving TFS and Jira services to the `integrations` directory and correcting imports across the codebase. - Updated imports in various action files, API routes, and components to reflect the new structure. - Removed obsolete `jira-advanced-filters.ts`, `jira-analytics.ts`, `jira-analytics-cache.ts`, `jira-anomaly-detection.ts`, `jira-scheduler.ts`, `jira.ts`, and `tfs.ts` files to streamline the codebase. - Added new tasks in `TODO.md` for future cleaning and organization of service imports.
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { tfsService } from '@/services/integrations/tfs';
|
|
|
|
/**
|
|
* Route POST /api/tfs/sync
|
|
* Synchronise les Pull Requests TFS/Azure DevOps avec la base locale
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
export async function POST(_request: Request) {
|
|
try {
|
|
console.log('🔄 Début de la synchronisation TFS manuelle...');
|
|
|
|
// Effectuer la synchronisation via le service singleton
|
|
const result = await tfsService.syncTasks();
|
|
|
|
if (result.success) {
|
|
return NextResponse.json({
|
|
message: 'Synchronisation TFS terminée avec succès',
|
|
data: result,
|
|
});
|
|
} else {
|
|
return NextResponse.json(
|
|
{
|
|
error: 'Synchronisation TFS terminée avec des erreurs',
|
|
data: result,
|
|
},
|
|
{ status: 207 } // Multi-Status
|
|
);
|
|
}
|
|
} catch (error) {
|
|
console.error('❌ Erreur API sync TFS:', error);
|
|
|
|
return NextResponse.json(
|
|
{
|
|
error: 'Erreur interne lors de la synchronisation',
|
|
details: error instanceof Error ? error.message : 'Erreur inconnue',
|
|
},
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Route GET /api/tfs/sync
|
|
* Teste la connexion TFS
|
|
*/
|
|
export async function GET() {
|
|
try {
|
|
// Tester la connexion via le service singleton
|
|
const isConnected = await tfsService.testConnection();
|
|
|
|
if (isConnected) {
|
|
return NextResponse.json({
|
|
message: 'Connexion TFS OK',
|
|
connected: true,
|
|
});
|
|
} else {
|
|
return NextResponse.json(
|
|
{
|
|
error: 'Connexion TFS échouée',
|
|
connected: false,
|
|
},
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
} catch (error) {
|
|
console.error('❌ Erreur test connexion TFS:', error);
|
|
|
|
return NextResponse.json(
|
|
{
|
|
error: 'Erreur interne',
|
|
details: error instanceof Error ? error.message : 'Erreur inconnue',
|
|
connected: false,
|
|
},
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|