Skip to content

Commit

Permalink
refactor(server): port env (immich-app#13158)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored and Yosi Taguri committed Oct 3, 2024
1 parent 27ae7fd commit bf4ccff
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/src/interfaces/config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { VectorExtension } from 'src/interfaces/database.interface';
export const IConfigRepository = 'IConfigRepository';

export interface EnvData {
port: number;
environment: ImmichEnvironment;
configFile?: string;
logLevel?: LogLevel;
Expand Down
1 change: 1 addition & 0 deletions server/src/repositories/config.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EnvData, IConfigRepository } from 'src/interfaces/config.interface';
export class ConfigRepository implements IConfigRepository {
getEnv(): EnvData {
return {
port: Number(process.env.IMMICH_PORT) || 3001,
environment: process.env.IMMICH_ENV as ImmichEnvironment,
configFile: process.env.IMMICH_CONFIG_FILE,
logLevel: process.env.IMMICH_LOG_LEVEL as LogLevel,
Expand Down
3 changes: 1 addition & 2 deletions server/src/workers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ async function bootstrap() {

otelStart(otelPort);

const port = Number(process.env.IMMICH_PORT) || 3001;
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { bufferLogs: true });
const logger = await app.resolve<ILoggerRepository>(ILoggerRepository);
const configRepository = app.get<IConfigRepository>(IConfigRepository);

const { environment } = configRepository.getEnv();
const { environment, port } = configRepository.getEnv();
const isDev = environment === ImmichEnvironment.DEVELOPMENT;

logger.setAppName('Api');
Expand Down
1 change: 1 addition & 0 deletions server/test/repositories/config.repository.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DatabaseExtension } from 'src/interfaces/database.interface';
import { Mocked, vitest } from 'vitest';

const envData: EnvData = {
port: 3001,
environment: ImmichEnvironment.PRODUCTION,

database: {
Expand Down

0 comments on commit bf4ccff

Please sign in to comment.