mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
/**
|
|
* POST /diffs endpoint - Get diffs for the main project
|
|
*/
|
|
|
|
import type { Request, Response } from 'express';
|
|
import { getErrorMessage, logError } from '../common.js';
|
|
import { getGitRepositoryDiffs } from '../../common.js';
|
|
|
|
export function createDiffsHandler() {
|
|
return async (req: Request, res: Response): Promise<void> => {
|
|
try {
|
|
const { projectPath } = req.body as { projectPath: string };
|
|
|
|
if (!projectPath) {
|
|
res.status(400).json({ success: false, error: 'projectPath required' });
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const result = await getGitRepositoryDiffs(projectPath);
|
|
res.json({
|
|
success: true,
|
|
diff: result.diff,
|
|
files: result.files,
|
|
hasChanges: result.hasChanges,
|
|
});
|
|
} catch (innerError) {
|
|
logError(innerError, 'Git diff failed');
|
|
res.json({ success: true, diff: '', files: [], hasChanges: false });
|
|
}
|
|
} catch (error) {
|
|
logError(error, 'Get diffs failed');
|
|
res.status(500).json({ success: false, error: getErrorMessage(error) });
|
|
}
|
|
};
|
|
}
|