mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-08 20:37:41 +00:00
ditch nestjs config module, add static config serfice
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import * as env from 'dotenv';
|
||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import { LrtCategory } from '../KodiApi/LRT/LrtApiClient/Entity/lrt-category.entity';
|
||||
import { join } from 'path';
|
||||
|
||||
env.config();
|
||||
|
||||
class ConfigService {
|
||||
public getEnv(key: string): any {
|
||||
return process.env[key];
|
||||
}
|
||||
|
||||
public getPort(): number {
|
||||
const port = this.getEnv('PORT');
|
||||
|
||||
return port ? parseInt(port) : 3000;
|
||||
}
|
||||
|
||||
public getTypeOrmConfig(): TypeOrmModuleOptions {
|
||||
return {
|
||||
type: 'sqlite',
|
||||
database: this.getEnv('DB_PATH'),
|
||||
entities: [LrtCategory],
|
||||
};
|
||||
}
|
||||
|
||||
public getStaticRequestsLogPath(): string {
|
||||
return join(this.getRootPath(), this.getEnv('LOG_FILE_REQUESTS'));
|
||||
}
|
||||
|
||||
public getStaticFolder(): string {
|
||||
return join(this.getRootPath(), this.getEnv('STATIC_SERVE_FOLDER'));
|
||||
}
|
||||
|
||||
private getRootPath(): string {
|
||||
return join(__dirname, '../..');
|
||||
}
|
||||
}
|
||||
|
||||
export const configService = new ConfigService();
|
||||
Reference in New Issue
Block a user