26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { Controller, Get, Inject, Param, Request, UseGuards } from '@nestjs/common';
|
|
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
|
import { Logger } from 'winston';
|
|
import { OptionalJwtAuthGuard } from '../jwt-auth/optional-jwt-auth.guard';
|
|
import { BusinessListingService } from './business-listing.service';
|
|
import { CommercialPropertyService } from './commercial-property.service';
|
|
|
|
@Controller('listings/undefined')
|
|
export class UnknownListingsController {
|
|
constructor(
|
|
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
|
private readonly businessListingsService: BusinessListingService,
|
|
private readonly propertyListingsService: CommercialPropertyService,
|
|
) {}
|
|
|
|
@UseGuards(OptionalJwtAuthGuard)
|
|
@Get(':id')
|
|
async findById(@Request() req, @Param('id') id: string): Promise<any> {
|
|
try {
|
|
return await this.businessListingsService.findBusinessesById(id, req.user);
|
|
} catch (error) {
|
|
return await this.propertyListingsService.findCommercialPropertiesById(id, req.user);
|
|
}
|
|
}
|
|
}
|