fix: resolve API inconsistencies found by Mokoto
- Bug 1: No fix needed - frontend already uses PUT for document updates - Bug 2: Changed folders API to use 'project' param (matches documents) - Bug 3: GET /folders now works without project filter (lists all folders) Changes: - folders.js: Accept 'project' instead of 'projectId', make it optional - folderService.js: Support listing all folders when projectId is null - api.js: Updated getFolders() to use 'project' param consistently
This commit is contained in:
@@ -11,15 +11,12 @@ import { NotFoundError, ValidationError } from '../utils/errors.js';
|
||||
const router = Router();
|
||||
router.use(authMiddleware);
|
||||
|
||||
// GET /folders?projectId=X&parentId=Y - List folders
|
||||
// GET /folders?project=X&parentId=Y - List folders (project is optional, matches documents API)
|
||||
router.get('/', async (req, res) => {
|
||||
try {
|
||||
const { projectId, parentId } = req.query;
|
||||
if (!projectId) {
|
||||
throw new ValidationError('projectId query parameter is required');
|
||||
}
|
||||
const { project, parentId } = req.query;
|
||||
const folderService = getFolderService();
|
||||
const folders = await folderService.getFolders(projectId, parentId || null);
|
||||
const folders = await folderService.getFolders(project || null, parentId || null);
|
||||
res.json({ folders });
|
||||
} catch (err) {
|
||||
if (err instanceof ValidationError) {
|
||||
|
||||
Reference in New Issue
Block a user