mppr/src/zvksmetrics/zvksmetrics.controller.ts

37 lines
1.2 KiB
TypeScript

import { Body, ConfigurableModuleBuilder, Controller, Get, Options, Param, ParseIntPipe, Post} from '@nestjs/common';
import { ZvksmetricsService } from './zvksmetrics.service';
@Controller('api')
export class ZvksmetricsController {
constructor(private readonly metricsService: ZvksmetricsService) {}
@Get('ranges')
async getHello(): Promise<any> {
let a: number = 7;
let b: number = 9;
let sum: any = {value: (a+b)/4*b+a};
// let a = await this.metricsService.showStatus();
console.log(sum.value);
return sum.value;
}
//Заглушка для будующей API
@Options('config/:code')
async showConfig (@Param('code', ParseIntPipe) code: number): Promise<JSON>{
let ret : JSON = JSON.parse('{"result":"null"}');
if(code === 9999){
return await this.metricsService.showRangesConfig('File Name');
}
return ret;
}
@Post('input')
async getPostMessage (@Body() inputMetrics : any) : Promise<string> {
//console.log(inputMetrics);
let out: any = await this.metricsService.useStatusModel(inputMetrics);
return out;
}
}