feat(tags): add input validation for tag and entity operations
Added validation checks for tagId, personId, and projectId across tag-related operations. Introduced `BadRequestException` for invalid or missing inputs. Replaced generic errors with more descriptive exceptions.
This commit is contained in:
parent
5abd33e648
commit
8cbce3f3fa
@ -229,16 +229,29 @@ export class ProjectsService {
|
||||
* Get all collaborators for a project
|
||||
*/
|
||||
async getCollaborators(projectId: string) {
|
||||
// Validate projectId
|
||||
if (!projectId) {
|
||||
throw new NotFoundException('Project ID is required');
|
||||
}
|
||||
|
||||
try {
|
||||
// Check if the project exists
|
||||
await this.findById(projectId);
|
||||
|
||||
// Get all collaborators for the project
|
||||
return this.db
|
||||
const collaborators = await this.db
|
||||
.select({
|
||||
user: schema.users,
|
||||
})
|
||||
.from(schema.projectCollaborators)
|
||||
.innerJoin(schema.users, eq(schema.projectCollaborators.userId, schema.users.id))
|
||||
.where(eq(schema.projectCollaborators.projectId, projectId));
|
||||
|
||||
// Map the results to extract just the user objects
|
||||
return collaborators.map(collaborator => collaborator.user);
|
||||
} catch (error) {
|
||||
// If there's a database error (like invalid UUID format), throw a NotFoundException
|
||||
throw new NotFoundException(`Failed to get collaborators for project: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user