feat(core): Add endpoint PATCH /projects/:projectId/folders/:folderId (no-changelog) (#13454)

This commit is contained in:
Ricardo Espinoza
2025-02-26 07:01:22 -05:00
committed by GitHub
parent b50658cbc6
commit f7f5f5e95c
10 changed files with 217 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
import { CreateFolderDto } from '@n8n/api-types';
import { CreateFolderDto, UpdateFolderDto } from '@n8n/api-types';
import { Response } from 'express';
import { Post, RestController, ProjectScope, Body, Get } from '@/decorators';
import { Post, RestController, ProjectScope, Body, Get, Patch } from '@/decorators';
import { FolderNotFoundError } from '@/errors/folder-not-found.error';
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
@@ -48,4 +48,23 @@ export class ProjectController {
throw new InternalServerError();
}
}
@Patch('/:folderId')
@ProjectScope('folder:update')
async updateFolder(
req: AuthenticatedRequest<{ projectId: string; folderId: string }>,
_res: Response,
@Body payload: UpdateFolderDto,
) {
const { projectId, folderId } = req.params;
try {
await this.folderService.updateFolder(folderId, projectId, payload);
} catch (e) {
if (e instanceof FolderNotFoundError) {
throw new NotFoundError(e.message);
}
throw new InternalServerError();
}
}
}