import { Controller, Get, Param } from '@nestjs/common'; import { ParkioService } from './parkio.service'; @Controller('parkio') export class ParkioController { constructor( private readonly parkioService: ParkioService ) {} @Get('auctions') async getAuctions () { return this.parkioService.fetchAuctions(); } @Get('domains') async getDomains () { return this.parkioService.fetchAllDomains(); } @Get('short/:maxLength') async getShort (@Param('maxLength') maxLength: number) { return { maxLength, domains: (await this.parkioService.fetchAllDomains()).filter( parsedDomain => parsedDomain.domain_length <= maxLength ), auctions: (await this.parkioService.fetchAuctions()).filter( parsedAuction => parsedAuction.domain_length <= maxLength ), } } }