Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import { Controller, Get, Post, Put, Param, Body, Req } from '@nestjs/common'; import { OnboardingService } from './onboarding.service'; import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'; @Controller('api/v1/onboarding') @ApiTags('Onboarding') export class OnboardingController { constructor(private readonly onboardingService: OnboardingService) {} private getContext(req: any) { const tenantId = req.user?.tenantId || req.headers['x-tenant-id'] || 'SYSTEM'; const userId = req.user?.id || req.headers['x-user-id'] || 'system-user-id'; return { tenantId, userId }; } @Get('steps') @ApiOperation({ summary: 'Get steps operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) async getSteps(@Req() req: any) { const ctx = this.getContext(req); return this.onboardingService.getSteps(ctx.tenantId); } @Get('progress') @ApiOperation({ summary: 'Get progress operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) async getProgress(@Req() req: any) { const ctx = this.getContext(req); return this.onboardingService.getProgress(ctx.tenantId); } @Post('steps/:stepKey/complete') @ApiOperation({ summary: 'Complete step operation' }) @ApiResponse({ status: 201, description: 'Operation successful' }) async completeStep( @Param('stepKey') stepKey: string, @Body() body: any, @Req() req: any, ) { const ctx = this.getContext(req); return this.onboardingService.saveStep( ctx.tenantId, stepKey, body, ctx.userId, ); } @Post('steps/:stepKey/skip') @ApiOperation({ summary: 'Skip step operation' }) @ApiResponse({ status: 201, description: 'Operation successful' }) async skipStep(@Param('stepKey') stepKey: string, @Req() req: any) { const ctx = this.getContext(req); return this.onboardingService.skipStep(ctx.tenantId, stepKey); } @Post('complete') @ApiOperation({ summary: 'Complete onboarding operation' }) @ApiResponse({ status: 201, description: 'Operation successful' }) async completeOnboarding(@Req() req: any) { const ctx = this.getContext(req); return this.onboardingService.completeOnboarding(ctx.tenantId, ctx.userId); } } |