import { Controller, Post, Body, Get } from '@nestjs/common'; import { TestService } from './test.service'; import { Public } from '../src/common/auth/decorators/public.decorator'; @Controller('test') export class TestController { constructor(private readonly testService: TestService) {} @Get('status') @Public() getStatus() { return { message: 'Test module is working', timestamp: new Date().toISOString(), services: { redis: 'available', kafka: 'available', }, }; } @Post('kafka') @Public() async testKafka(@Body() data: Record) { try { await this.testService.publishKafkaEvent('test-topic', { message: 'Hello from WWJCloud Test Module!', data, timestamp: new Date().toISOString(), }); return { success: true, message: 'Event published to Kafka successfully', topic: 'test-topic', data, }; } catch (error) { return { success: false, message: 'Failed to publish event to Kafka', error: error instanceof Error ? error.message : String(error), }; } } @Post('redis') @Public() async testRedis(@Body() data: Record) { try { const jobId = await this.testService.enqueueRedisJob('test-job', { message: 'Hello from WWJCloud Test Module!', data, timestamp: new Date().toISOString(), }); return { success: true, message: 'Job queued to Redis successfully', jobId, data, }; } catch (error) { return { success: false, message: 'Failed to queue job to Redis', error: error instanceof Error ? error.message : String(error), }; } } }