mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-08 20:37:41 +00:00
all-files: inject database connection, create title entity
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
import { Column, Entity, PrimaryColumn } from 'typeorm';
|
||||||
|
import { TitleTypeEnum } from '../Enum/title-type.enum';
|
||||||
|
|
||||||
|
@Entity('titles')
|
||||||
|
export class TitleEntity {
|
||||||
|
@PrimaryColumn({ name: 'id' })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column({ name: 'title' })
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
@Column({ name: 'type' })
|
||||||
|
type: TitleTypeEnum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export enum TitleTypeEnum {
|
||||||
|
movie = 'movie',
|
||||||
|
show = 'show',
|
||||||
|
}
|
||||||
@@ -11,6 +11,11 @@ export class AllFilesController {
|
|||||||
return this.allFilesService.getMenu();
|
return this.allFilesService.getMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('titles')
|
||||||
|
async titles() {
|
||||||
|
return this.allFilesService.getAllTitles();
|
||||||
|
}
|
||||||
|
|
||||||
@Get('show')
|
@Get('show')
|
||||||
getShows() {
|
getShows() {
|
||||||
return { will: 'show shows list' };
|
return { will: 'show shows list' };
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { Module } from '@nestjs/common';
|
|||||||
import { AllFilesController } from './all-files.controller';
|
import { AllFilesController } from './all-files.controller';
|
||||||
import { AllFilesService } from './all-files.service';
|
import { AllFilesService } from './all-files.service';
|
||||||
import { KodiApiResponseFactory } from '../kodi-api-response.factory';
|
import { KodiApiResponseFactory } from '../kodi-api-response.factory';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { TitleEntity } from './Entity/title.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [],
|
imports: [TypeOrmModule.forFeature([TitleEntity])],
|
||||||
controllers: [AllFilesController],
|
controllers: [AllFilesController],
|
||||||
providers: [AllFilesService, KodiApiResponseFactory],
|
providers: [AllFilesService, KodiApiResponseFactory],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import ApiResponse from '../Dto/api-response.dto';
|
import ApiResponse from '../Dto/api-response.dto';
|
||||||
import { KodiApiResponseFactory } from '../kodi-api-response.factory';
|
import { KodiApiResponseFactory } from '../kodi-api-response.factory';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
import { TitleEntity } from './Entity/title.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AllFilesService {
|
export class AllFilesService {
|
||||||
constructor(private readonly koiApiResponseFactory: KodiApiResponseFactory) {}
|
constructor(
|
||||||
|
private readonly koiApiResponseFactory: KodiApiResponseFactory,
|
||||||
|
@InjectRepository(TitleEntity)
|
||||||
|
private titleRepository: Repository<TitleEntity>,
|
||||||
|
) {}
|
||||||
|
|
||||||
getMenu(): ApiResponse {
|
getMenu(): ApiResponse {
|
||||||
const apiResponse = this.koiApiResponseFactory.createApiResponse();
|
const apiResponse = this.koiApiResponseFactory.createApiResponse();
|
||||||
@@ -21,4 +28,9 @@ export class AllFilesService {
|
|||||||
|
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAllTitles() {
|
||||||
|
return this.titleRepository.find();
|
||||||
|
//return { todo: true };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { Column, Entity, PrimaryColumn } from 'typeorm';
|
|||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class LrtCategory {
|
export class LrtCategory {
|
||||||
|
|
||||||
@PrimaryColumn({ name: 'category_url' })
|
@PrimaryColumn({ name: 'category_url' })
|
||||||
categoryUrl: string;
|
categoryUrl: string;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as env from 'dotenv';
|
|||||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||||
import { LrtCategory } from '../KodiApi/LRT/LrtApiClient/Entity/lrt-category.entity';
|
import { LrtCategory } from '../KodiApi/LRT/LrtApiClient/Entity/lrt-category.entity';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
import { TitleEntity } from '../KodiApi/AllFiles/Entity/title.entity';
|
||||||
|
|
||||||
env.config();
|
env.config();
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ export class ConfigService {
|
|||||||
return {
|
return {
|
||||||
type: 'sqlite',
|
type: 'sqlite',
|
||||||
database: this.getEnv('DB_PATH'),
|
database: this.getEnv('DB_PATH'),
|
||||||
entities: [LrtCategory],
|
entities: [LrtCategory, TitleEntity],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user