start local fs video files scanner service

This commit is contained in:
Jurgis Sakalauskas
2023-01-05 17:39:35 +02:00
parent 3c9ea2fb39
commit 1631a97417
16 changed files with 432 additions and 9 deletions
+6
View File
@@ -2,12 +2,14 @@ import * as env from 'dotenv';
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { TypeOrmConfig } from './type-orm.config';
import { PathsConfig } from './paths.config';
import { VideoFilesConfig } from './video-files.config';
env.config();
export class ConfigService {
private typeOrmConfig: TypeOrmConfig = new TypeOrmConfig(this);
private pathsConfig: PathsConfig = new PathsConfig(this);
private videoFilesConfig: VideoFilesConfig = new VideoFilesConfig(this);
public getEnv(key: string): any {
return process.env[key];
@@ -26,6 +28,10 @@ export class ConfigService {
public getPaths(): PathsConfig {
return this.pathsConfig;
}
public getVideoFilesConfig(): VideoFilesConfig {
return this.videoFilesConfig;
}
}
export const configService = new ConfigService();
+1 -1
View File
@@ -18,7 +18,7 @@ export class PathsConfig {
return this.getPathByEnvKey('RECENT_SEARCHES_FOLDER');
}
private getPathByEnvKey(key: string) {
public getPathByEnvKey(key: string) {
const relPath = this.configService.getEnv(key);
return this.getPath(relPath);
+16
View File
@@ -0,0 +1,16 @@
import { ConfigService } from './config.service';
import { join } from 'path';
export class VideoFilesConfig {
constructor(private readonly configService: ConfigService) {
this.configService = configService;
}
public getVideoFilesFolders(): string[] {
return JSON.parse(this.configService.getEnv('VIDEO_FILES_FOLDERS'));
}
public getVideoFilesExt(): string[] {
return JSON.parse(this.configService.getEnv('VIDEO_FILES_EXT'));
}
}