mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-08 20:37:41 +00:00
start lrt api client
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
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';
|
||||
import { LrtApiClient } from './lrt-api.client';
|
||||
|
||||
@Controller('api/lrt')
|
||||
export class LrtController {
|
||||
constructor(
|
||||
private readonly lrtService: LrtService,
|
||||
private readonly httpService: HttpService,
|
||||
private readonly lrtApiClient: LrtApiClient,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@@ -27,19 +26,15 @@ export class LrtController {
|
||||
|
||||
@Get('recent')
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
@Get('cat/:id')
|
||||
getCategory(@Req() request: Request, @Param('id') id: number) {
|
||||
async getCategory(@Req() request: Request, @Param('id') id: number) {
|
||||
return {
|
||||
mod: 'lrt - category',
|
||||
path: request.url,
|
||||
@@ -47,12 +42,13 @@ export class LrtController {
|
||||
};
|
||||
}
|
||||
|
||||
@Get('tema/:tema')
|
||||
getTema(@Req() request: Request, @Param('tema') tema: string) {
|
||||
@Get('tema/:topic')
|
||||
async getTema(@Req() request: Request, @Param('topic') topic: string) {
|
||||
const resp = await this.lrtApiClient.getSearch(topic);
|
||||
return {
|
||||
mod: 'lrt - category',
|
||||
path: request.url,
|
||||
tema: tema,
|
||||
topic: resp,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user