11using Microsoft . AspNetCore . Authorization ;
22using Microsoft . AspNetCore . Mvc ;
33using sparkly_server . DTO . Projects ;
4+ using sparkly_server . DTO . Projects . Feed ;
45using sparkly_server . Services . Projects ;
56
67namespace sparkly_server . Controllers . Projects
@@ -13,24 +14,54 @@ public class ProjectsController : ControllerBase
1314 private readonly IProjectService _projects ;
1415
1516 public ProjectsController ( IProjectService projects ) => _projects = projects ;
16-
17- // Random projects to feed the homepage
17+
18+ /// <summary>
19+ /// Retrieves a specified number of random public projects.
20+ /// </summary>
21+ /// <param name="take">The number of projects to retrieve. Defaults to 20 if not specified.</param>
22+ /// <param name="ct">A token to observe while waiting for the task to complete.</param>
23+ /// <returns>An HTTP response containing a list of random public projects.</returns>
1824 [ HttpGet ( "random" ) ]
1925 public async Task < IActionResult > GetRandomProjects ( [ FromQuery ] int take = 20 , CancellationToken ct = default )
2026 {
2127 var response = await _projects . GetRandomPublicAsync ( take , ct ) ;
2228 return Ok ( response ) ;
2329 }
24-
25- // Get project by id
30+
31+ /// <summary>
32+ /// Retrieves a feed of projects based on the specified query parameters.
33+ /// </summary>
34+ /// <param name="query">The query parameters used to filter and paginate the project feed.</param>
35+ /// <param name="ct">A token to observe while waiting for the task to complete.</param>
36+ /// <returns>An HTTP response containing the requested project feed.</returns>
37+ [ HttpGet ( "feed" ) ]
38+ public async Task < IActionResult > GetProjectsFeed (
39+ [ FromQuery ] ProjectFeedQuery query ,
40+ CancellationToken ct = default )
41+ {
42+ var feed = await _projects . GetFeedAsync ( query , ct ) ;
43+ return Ok ( feed ) ;
44+ }
45+
46+
47+ /// <summary>
48+ /// Retrieves a project by its unique identifier.
49+ /// </summary>
50+ /// <param name="projectId">The unique identifier of the project to retrieve.</param>
51+ /// <param name="ct">A token to observe while waiting for the task to complete.</param>
52+ /// <returns>An HTTP response containing the project details.</returns>
2653 [ HttpGet ( "{projectId:guid}" ) ]
2754 public async Task < IActionResult > GetProjectById ( Guid projectId , CancellationToken ct = default )
2855 {
2956 var project = await _projects . GetProjectByIdAsync ( projectId , ct ) ;
3057 return Ok ( project ) ;
3158 }
32-
33- // Create project
59+
60+ /// <summary>
61+ /// Creates a new project with the specified details.
62+ /// </summary>
63+ /// <param name="request">The request object containing the project name, description, and visibility settings.</param>
64+ /// <returns>A response containing the created project's details.</returns>
3465 [ HttpPost ( "create" ) ]
3566 public async Task < IActionResult > CreateProject ( [ FromBody ] CreateProjectRequest request )
3667 {
@@ -41,7 +72,13 @@ public async Task<IActionResult> CreateProject([FromBody] CreateProjectRequest r
4172 return Ok ( response ) ;
4273 }
4374
44- // Update project by id (admin only)
75+ /// <summary>
76+ /// Updates the details of an existing project. (Admin project only)
77+ /// </summary>
78+ /// <param name="projectId">The unique identifier of the project to be updated.</param>
79+ /// <param name="request">An object containing the updated project details, such as name, description, and visibility.</param>
80+ /// <param name="cn">A token to observe while waiting for the task to complete.</param>
81+ /// <returns>A no-content HTTP response indicating the project was successfully updated.</returns>
4582 [ HttpPut ( "update/{projectId:guid}" ) ]
4683 public async Task < IActionResult > UpdateProject (
4784 Guid projectId ,
@@ -51,8 +88,13 @@ public async Task<IActionResult> UpdateProject(
5188 await _projects . UpdateProjectAsync ( projectId , request , cn ) ;
5289 return NoContent ( ) ;
5390 }
54-
55- // Delete project by id (admin only)
91+
92+ /// <summary>
93+ /// Deletes a project identified by its unique ID. (Admin project only)
94+ /// </summary>
95+ /// <param name="projectId">The unique identifier of the project to delete.</param>
96+ /// <param name="ct">A token to observe while waiting for the task to complete.</param>
97+ /// <returns>An HTTP response with no content if the deletion was successful.</returns>
5698 [ HttpDelete ( "delete/{projectId:guid}" ) ]
5799 public async Task < IActionResult > DeleteProject ( Guid projectId , CancellationToken ct = default )
58100 {
0 commit comments