add axios HttpService, test on recent

This commit is contained in:
Jurgis Sakalauskas
2022-12-07 17:44:33 +02:00
parent e92b5034c0
commit 059904d745
4 changed files with 93 additions and 13 deletions
+11 -2
View File
@@ -1,10 +1,15 @@
import { Controller, Get, Param, Query, Req } from '@nestjs/common';
import { Request } from 'express';
import { LrtService } from './lrt.service';
import { HttpService } from '@nestjs/axios';
import { firstValueFrom } from 'rxjs';
@Controller('api/lrt')
export class LrtController {
constructor(private readonly lrtService: LrtService) {}
constructor(
private readonly lrtService: LrtService,
private readonly httpService: HttpService,
) {}
@Get()
getLrtMenu() {
@@ -21,11 +26,15 @@ export class LrtController {
}
@Get('recent')
getRecent(@Req() request: Request) {
async getRecent(@Req() request: Request) {
const resp = await firstValueFrom(
this.httpService.get('http://localhost:3000/api'),
);
return {
mod: 'lrt',
path: request.url,
recent: true,
resp: resp.data,
};
}
+2
View File
@@ -2,8 +2,10 @@ import { Module } from '@nestjs/common';
import { LrtController } from './lrt.controller';
import { LrtService } from './lrt.service';
import { KodiApiResponseFactory } from '../kodi-api-response.factory';
import { HttpModule } from '@nestjs/axios';
@Module({
imports: [HttpModule],
controllers: [LrtController],
providers: [KodiApiResponseFactory, LrtService],
})