Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { SearchModule } from './search/search.module';
import { AnalyticsModule } from './analytics/analytics.module';

import { MessagingModule } from './messaging/messaging.module';

Check warning on line 11 in src/app.module.ts

View workflow job for this annotation

GitHub Actions / validate

'MessagingModule' is defined but never used. Allowed unused vars must match /^_/u
import { IndexOptimizationModule } from './database/index-optimization/index-optimization.module';
import { RateLimitingModule } from './rate-limiting/rate-limiting.module';
import { QuotaGuard } from './rate-limiting/guards/quota.guard';
Expand All @@ -31,6 +31,7 @@
import { CachingModule } from './caching/caching.module';
import { CoursesModule } from './courses/courses.module';
import { AuthModule } from './auth/auth.module';
import { CohortsModule } from './cohorts/cohorts.module';

const featureFlags = loadFeatureFlags();

Expand Down Expand Up @@ -65,6 +66,7 @@

// ✅ courses module with enrollment and prerequisite enforcement
CoursesModule,
CohortsModule,
],
controllers: [AppController],
providers: [
Expand Down
129 changes: 129 additions & 0 deletions src/cohorts/cohorts.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import {

Check failure on line 1 in src/cohorts/cohorts.controller.ts

View workflow job for this annotation

GitHub Actions / validate

Replace `⏎··Controller,⏎··Post,⏎··Get,⏎··Body,⏎··Param,⏎··Req,⏎··UseGuards,⏎··Delete,⏎` with `·Controller,·Post,·Get,·Body,·Param,·Req,·UseGuards,·Delete·`
Controller,
Post,
Get,
Body,
Param,
Req,
UseGuards,
Delete,
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { CohortsService } from './cohorts.service';
import { CreateCohortDto } from './dto/create-cohort.dto';
import { AddCohortMemberDto } from './dto/add-cohort-member.dto';
import { CreateCohortThreadDto } from './dto/create-cohort-thread.dto';
import { CreateCohortCommentDto } from './dto/create-cohort-comment.dto';
import { CreateCohortAssignmentDto } from './dto/create-cohort-assignment.dto';

@ApiTags('Cohorts')
@Controller('cohorts')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
export class CohortsController {
constructor(private readonly cohortsService: CohortsService) {}

@Post()
@ApiOperation({ summary: 'Create a new cohort for collaborative learning' })
@ApiResponse({ status: 201, description: 'Cohort created successfully' })
createCohort(@Body() dto: CreateCohortDto, @Req() req: any) {
return this.cohortsService.createCohort(dto, req.user.id);
}

@Get()
@ApiOperation({ summary: 'List cohorts the authenticated user belongs to' })
getCohorts(@Req() req: any) {
return this.cohortsService.getCohorts(req.user.id);
}

@Get(':id')
@ApiOperation({ summary: 'Get cohort details' })
getCohort(@Param('id') id: string, @Req() req: any) {
return this.cohortsService.getCohort(id, req.user.id);
}

@Post(':id/members')
@ApiOperation({ summary: 'Add a member to a cohort' })
addCohortMember(

Check failure on line 48 in src/cohorts/cohorts.controller.ts

View workflow job for this annotation

GitHub Actions / validate

Replace `⏎····@Param('id')·id:·string,⏎····@Body()·dto:·AddCohortMemberDto,⏎····@Req()·req:·any,⏎··` with `@Param('id')·id:·string,·@Body()·dto:·AddCohortMemberDto,·@Req()·req:·any`
@Param('id') id: string,
@Body() dto: AddCohortMemberDto,
@Req() req: any,
) {
return this.cohortsService.addMember(id, req.user.id, dto);
}

@Delete(':id/members/:memberId')
@ApiOperation({ summary: 'Remove a member from a cohort' })
removeCohortMember(
@Param('id') id: string,
@Param('memberId') memberId: string,
@Req() req: any,
) {
return this.cohortsService.removeMember(id, req.user.id, memberId);
}

@Get(':id/members')
@ApiOperation({ summary: 'List cohort members' })
listMembers(@Param('id') id: string, @Req() req: any) {
return this.cohortsService.listMembers(id, req.user.id);
}

@Post(':id/threads')
@ApiOperation({ summary: 'Create a discussion thread inside a cohort' })
createThread(

Check failure on line 74 in src/cohorts/cohorts.controller.ts

View workflow job for this annotation

GitHub Actions / validate

Replace `⏎····@Param('id')·id:·string,⏎····@Body()·dto:·CreateCohortThreadDto,⏎····@Req()·req:·any,⏎··` with `@Param('id')·id:·string,·@Body()·dto:·CreateCohortThreadDto,·@Req()·req:·any`
@Param('id') id: string,
@Body() dto: CreateCohortThreadDto,
@Req() req: any,
) {
return this.cohortsService.createThread(id, req.user.id, dto);
}

@Get(':id/threads')
@ApiOperation({ summary: 'List discussion threads inside a cohort' })
getThreads(@Param('id') id: string, @Req() req: any) {
return this.cohortsService.listThreads(id, req.user.id);
}

@Get(':id/threads/:threadId')
@ApiOperation({ summary: 'Get a cohort discussion thread with comments' })
getThread(@Param('threadId') threadId: string, @Req() req: any) {
return this.cohortsService.getThread(threadId, req.user.id);
}

@Post('threads/:threadId/comments')
@ApiOperation({ summary: 'Add a comment to a cohort discussion thread' })
addComment(
@Param('threadId') threadId: string,
@Body() dto: CreateCohortCommentDto,
@Req() req: any,
) {
return this.cohortsService.addComment(threadId, req.user.id, dto);
}

@Post(':id/assignments')
@ApiOperation({ summary: 'Create an assignment for a cohort' })
createAssignment(
@Param('id') id: string,
@Body() dto: CreateCohortAssignmentDto,
@Req() req: any,
) {
return this.cohortsService.createAssignment(id, req.user.id, dto);
}

@Get(':id/assignments')
@ApiOperation({ summary: 'List assignments for a cohort' })
getAssignments(@Param('id') id: string, @Req() req: any) {
return this.cohortsService.listAssignments(id, req.user.id);
}

@Get(':id/assignments/:assignmentId')
@ApiOperation({ summary: 'Get assignment details for a cohort' })
getAssignment(
@Param('id') id: string,
@Param('assignmentId') assignmentId: string,
@Req() req: any,
) {
return this.cohortsService.getAssignment(id, assignmentId, req.user.id);
}
}
25 changes: 25 additions & 0 deletions src/cohorts/cohorts.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CohortsController } from './cohorts.controller';
import { CohortsService } from './cohorts.service';
import { Cohort } from './entities/cohort.entity';
import { CohortMember } from './entities/cohort-member.entity';
import { CohortThread } from './entities/cohort-thread.entity';
import { CohortComment } from './entities/cohort-comment.entity';
import { CohortAssignment } from './entities/cohort-assignment.entity';

@Module({
imports: [
TypeOrmModule.forFeature([

Check failure on line 13 in src/cohorts/cohorts.module.ts

View workflow job for this annotation

GitHub Actions / validate

Replace `⏎······Cohort,⏎······CohortMember,⏎······CohortThread,⏎······CohortComment,⏎······CohortAssignment,⏎····` with `Cohort,·CohortMember,·CohortThread,·CohortComment,·CohortAssignment`
Cohort,
CohortMember,
CohortThread,
CohortComment,
CohortAssignment,
]),
],
controllers: [CohortsController],
providers: [CohortsService],
exports: [CohortsService],
})
export class CohortsModule {}
Loading
Loading