mirror of
https://github.com/immich-app/immich.git
synced 2025-01-16 16:56:46 +01:00
refactor(server): port env (#13158)
This commit is contained in:
parent
bf43c32dbf
commit
892a35acb5
4 changed files with 4 additions and 2 deletions
|
@ -4,6 +4,7 @@ import { VectorExtension } from 'src/interfaces/database.interface';
|
||||||
export const IConfigRepository = 'IConfigRepository';
|
export const IConfigRepository = 'IConfigRepository';
|
||||||
|
|
||||||
export interface EnvData {
|
export interface EnvData {
|
||||||
|
port: number;
|
||||||
environment: ImmichEnvironment;
|
environment: ImmichEnvironment;
|
||||||
configFile?: string;
|
configFile?: string;
|
||||||
logLevel?: LogLevel;
|
logLevel?: LogLevel;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { EnvData, IConfigRepository } from 'src/interfaces/config.interface';
|
||||||
export class ConfigRepository implements IConfigRepository {
|
export class ConfigRepository implements IConfigRepository {
|
||||||
getEnv(): EnvData {
|
getEnv(): EnvData {
|
||||||
return {
|
return {
|
||||||
|
port: Number(process.env.IMMICH_PORT) || 3001,
|
||||||
environment: process.env.IMMICH_ENV as ImmichEnvironment,
|
environment: process.env.IMMICH_ENV as ImmichEnvironment,
|
||||||
configFile: process.env.IMMICH_CONFIG_FILE,
|
configFile: process.env.IMMICH_CONFIG_FILE,
|
||||||
logLevel: process.env.IMMICH_LOG_LEVEL as LogLevel,
|
logLevel: process.env.IMMICH_LOG_LEVEL as LogLevel,
|
||||||
|
|
|
@ -32,12 +32,11 @@ async function bootstrap() {
|
||||||
|
|
||||||
otelStart(otelPort);
|
otelStart(otelPort);
|
||||||
|
|
||||||
const port = Number(process.env.IMMICH_PORT) || 3001;
|
|
||||||
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { bufferLogs: true });
|
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { bufferLogs: true });
|
||||||
const logger = await app.resolve<ILoggerRepository>(ILoggerRepository);
|
const logger = await app.resolve<ILoggerRepository>(ILoggerRepository);
|
||||||
const configRepository = app.get<IConfigRepository>(IConfigRepository);
|
const configRepository = app.get<IConfigRepository>(IConfigRepository);
|
||||||
|
|
||||||
const { environment } = configRepository.getEnv();
|
const { environment, port } = configRepository.getEnv();
|
||||||
const isDev = environment === ImmichEnvironment.DEVELOPMENT;
|
const isDev = environment === ImmichEnvironment.DEVELOPMENT;
|
||||||
|
|
||||||
logger.setAppName('Api');
|
logger.setAppName('Api');
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { DatabaseExtension } from 'src/interfaces/database.interface';
|
||||||
import { Mocked, vitest } from 'vitest';
|
import { Mocked, vitest } from 'vitest';
|
||||||
|
|
||||||
const envData: EnvData = {
|
const envData: EnvData = {
|
||||||
|
port: 3001,
|
||||||
environment: ImmichEnvironment.PRODUCTION,
|
environment: ImmichEnvironment.PRODUCTION,
|
||||||
|
|
||||||
database: {
|
database: {
|
||||||
|
|
Loading…
Reference in a new issue