/** * POST /update endpoint - Update a feature */ import type { Request, Response } from 'express'; import { FeatureLoader } from '../../../services/feature-loader.js'; import type { Feature } from '@automaker/types'; import { getErrorMessage, logError } from '../common.js'; export function createUpdateHandler(featureLoader: FeatureLoader) { return async (req: Request, res: Response): Promise => { try { const { projectPath, featureId, updates, descriptionHistorySource, enhancementMode } = req.body as { projectPath: string; featureId: string; updates: Partial; descriptionHistorySource?: 'enhance' | 'edit'; enhancementMode?: 'improve' | 'technical' | 'simplify' | 'acceptance' | 'ux-reviewer'; }; if (!projectPath || !featureId || !updates) { res.status(400).json({ success: false, error: 'projectPath, featureId, and updates are required', }); return; } const updated = await featureLoader.update( projectPath, featureId, updates, descriptionHistorySource, enhancementMode ); res.json({ success: true, feature: updated }); } catch (error) { logError(error, 'Update feature failed'); res.status(500).json({ success: false, error: getErrorMessage(error) }); } }; }