mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core): Add endpoint GET /projects/:projectId/folders (no-changelog) (#13519)
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
import { CreateFolderDto, DeleteFolderDto, UpdateFolderDto } from '@n8n/api-types';
|
||||
import {
|
||||
CreateFolderDto,
|
||||
DeleteFolderDto,
|
||||
ListFolderQueryDto,
|
||||
UpdateFolderDto,
|
||||
} from '@n8n/api-types';
|
||||
import { Response } from 'express';
|
||||
|
||||
import { Post, RestController, ProjectScope, Body, Get, Patch, Delete } from '@/decorators';
|
||||
import { Post, RestController, ProjectScope, Body, Get, Patch, Delete, Query } 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';
|
||||
import type { ListQuery } from '@/requests';
|
||||
import { AuthenticatedRequest } from '@/requests';
|
||||
import { FolderService } from '@/services/folder.service';
|
||||
|
||||
@@ -86,4 +92,21 @@ export class ProjectController {
|
||||
throw new InternalServerError(undefined, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('/')
|
||||
@ProjectScope('folder:list')
|
||||
async listFolders(
|
||||
req: AuthenticatedRequest<{ projectId: string }>,
|
||||
res: Response,
|
||||
@Query payload: ListFolderQueryDto,
|
||||
) {
|
||||
const { projectId } = req.params;
|
||||
|
||||
const [data, count] = await this.folderService.getManyAndCount(
|
||||
projectId,
|
||||
payload as ListQuery.Options,
|
||||
);
|
||||
|
||||
res.json({ count, data });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user