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
97 changes: 95 additions & 2 deletions drips/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions drips/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@nestjs/jwt": "^11.0.2",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.2.5",
"@nestjs/typeorm": "^11.0.0",
"@types/joi": "^17.2.2",
"cache-manager": "^7.2.8",
Expand All @@ -41,6 +42,7 @@
"pg": "^8.17.2",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.1",
"typeorm": "^0.3.28"
},
"devDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions drips/src/bookings/bookings.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,46 @@ import {
UseGuards,
Request,
} from '@nestjs/common';
import {
ApiTags,
ApiOperation,
ApiResponse,
ApiBearerAuth,
} from '@nestjs/swagger';
import { BookingsService } from './bookings.service';
import { CreateBookingDto } from './dto/create-booking.dto';
import { UpdateBookingDto } from './dto/update-booking.dto';
import { BookingQueryDto } from './dto/booking-query.dto';

@ApiTags('Bookings')
@ApiBearerAuth()
@Controller('bookings')
export class BookingsController {
constructor(private readonly bookingsService: BookingsService) {}

@Post()
@ApiOperation({ summary: 'Create a new booking' })
@ApiResponse({ status: 201, description: 'The booking has been successfully created.' })
@ApiResponse({ status: 400, description: 'Bad Request.' })
@ApiResponse({ status: 401, description: 'Unauthorized.' })
async createBooking(@Request() req, @Body() createDto: CreateBookingDto) {
const userId = req.user.id; // From auth guard
return this.bookingsService.createBooking(userId, createDto);
}

@Patch(':id/confirm')
@ApiOperation({ summary: 'Confirm a booking' })
@ApiResponse({ status: 200, description: 'The booking has been confirmed.' })
@ApiResponse({ status: 404, description: 'Booking not found.' })
async confirmBooking(@Request() req, @Param('id') id: string) {
const userId = req.user.id;
return this.bookingsService.confirmBooking(id, userId);
}

@Patch(':id/cancel')
@ApiOperation({ summary: 'Cancel a booking' })
@ApiResponse({ status: 200, description: 'The booking has been cancelled.' })
@ApiResponse({ status: 404, description: 'Booking not found.' })
async cancelBooking(
@Request() req,
@Param('id') id: string,
Expand All @@ -41,13 +59,18 @@ export class BookingsController {
}

@Get()
@ApiOperation({ summary: 'Get all bookings for the authenticated user' })
@ApiResponse({ status: 200, description: 'Return all bookings.' })
async getBookings(@Request() req, @Query() query: BookingQueryDto) {
const userId = req.user.id;
const userRole = req.user.role; // 'mentee' or 'mentor'
return this.bookingsService.getBookings(userId, userRole, query);
}

@Get(':id')
@ApiOperation({ summary: 'Get a booking by ID' })
@ApiResponse({ status: 200, description: 'Return the booking.' })
@ApiResponse({ status: 404, description: 'Booking not found.' })
async getBookingById(@Request() req, @Param('id') id: string) {
const userId = req.user.id;
return this.bookingsService.getBookingById(id, userId);
Expand Down
21 changes: 21 additions & 0 deletions drips/src/bookings/dto/booking-query.dto.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
import { IsEnum, IsOptional, IsDateString, IsUUID } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { BookingStatus } from '../entities/booking.entity';

export class BookingQueryDto {
@ApiPropertyOptional({
enum: BookingStatus,
description: 'Filter by booking status',
})
@IsEnum(BookingStatus)
@IsOptional()
status?: BookingStatus;

@ApiPropertyOptional({
description: 'Filter by start date',
example: '2026-01-01T00:00:00Z',
})
@IsDateString()
@IsOptional()
startDate?: string;

@ApiPropertyOptional({
description: 'Filter by end date',
example: '2026-01-31T23:59:59Z',
})
@IsDateString()
@IsOptional()
endDate?: string;

@ApiPropertyOptional({
description: 'Filter by mentor ID',
example: '550e8400-e29b-41d4-a716-446655440000',
})
@IsUUID()
@IsOptional()
mentorId?: string;

@ApiPropertyOptional({
description: 'Filter by mentee ID',
example: '660e8400-e29b-41d4-a716-446655440000',
})
@IsUUID()
@IsOptional()
menteeId?: string;
Expand Down
17 changes: 17 additions & 0 deletions drips/src/bookings/dto/create-booking.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,37 @@ import {
IsString,
IsUUID,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateBookingDto {
@ApiProperty({
description: 'The ID of the mentor to book with',
example: '550e8400-e29b-41d4-a716-446655440000',
})
@IsUUID()
@IsNotEmpty()
mentorId: string;

@ApiProperty({
description: 'The start time of the booking',
example: '2026-01-25T10:00:00Z',
})
@IsDateString()
@IsNotEmpty()
startTime: string;

@ApiProperty({
description: 'The end time of the booking',
example: '2026-01-25T11:00:00Z',
})
@IsDateString()
@IsNotEmpty()
endTime: string;

@ApiPropertyOptional({
description: 'Optional notes for the booking',
example: 'I want to discuss NestJS Swagger implementation',
})
@IsString()
@IsOptional()
notes?: string;
Expand Down
11 changes: 11 additions & 0 deletions drips/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ async function bootstrap() {
}),
);

const { DocumentBuilder, SwaggerModule } = await import('@nestjs/swagger');
const config = new DocumentBuilder()
.setTitle('SkillSync Drips API')
.setDescription('The SkillSync Drips API documentation')
.setVersion('1.0')
.addBearerAuth()
.build();

const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('docs', app, document);

const configService = app.get(AppConfigService);
const port = configService.port;

Expand Down
Loading