mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-09 04:47:41 +00:00
add axios HttpService, test on recent
This commit is contained in:
@@ -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,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],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user