fix: allow folderId in updateDocument and pass it through route handler

- Add folderId parameter to updateDocument service method
- Extract folderId from request body in PUT /documents/:id route
- Fixes move document to folder functionality
This commit is contained in:
Hiro
2026-03-28 14:12:42 +00:00
parent 789e17ffac
commit 4e1d4f80cc
2 changed files with 4 additions and 2 deletions

View File

@@ -78,7 +78,7 @@ router.get('/:id', async (req, res) => {
// PUT /documents/:id - Update document
router.put('/:id', async (req, res) => {
try {
const { title, content, tags, type, priority, status } = req.body;
const { title, content, tags, type, priority, status, folderId } = req.body;
const docService = getDocumentService();
const doc = await docService.updateDocument(req.params.id, {
title,
@@ -87,6 +87,7 @@ router.put('/:id', async (req, res) => {
type,
priority,
status,
folderId,
});
res.json(doc);
} catch (err) {

View File

@@ -469,7 +469,7 @@ export class DocumentService {
};
}
async updateDocument(docId, { title, content, tags, type, priority, status }) {
async updateDocument(docId, { title, content, tags, type, priority, status, folderId }) {
const found = this._findDocById(docId);
if (!found) {
throw new NotFoundError('Document');
@@ -484,6 +484,7 @@ export class DocumentService {
if (priority !== undefined) meta.priority = priority;
if (status !== undefined) meta.status = status;
if (tags !== undefined) meta.tags = tags.filter(t => t);
if (folderId !== undefined) meta.folderId = folderId;
meta.updatedAt = now;
// Rewrite markdown file