homeweatherapi/src/app.controller.ts

28 lines
786 B
TypeScript

import { Controller, Get, Query, UseInterceptors } from '@nestjs/common';
import { AppService } from './app.service';
import { CacheInterceptor, CacheTTL } from '@nestjs/cache-manager';
import { HistoryQueryDto } from './dtos/history-query.dto';
import { GraphQueryDto } from './dtos/graph-query.dto';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
@UseInterceptors(CacheInterceptor)
@CacheTTL(60000)
getWeather() {
return this.appService.getWeather();
}
@Get('history')
getWeatherHistory(@Query() query: HistoryQueryDto) {
return this.appService.getWeatherHistory(query);
}
@Get('graph')
makeGraph(@Query() query: GraphQueryDto) {
return this.appService.graphWeatherHistory(query);
}
}