Skip to content

Commit

Permalink
refactor(server): port env
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 committed Oct 3, 2024
1 parent bf43c32 commit dd91f63
Show file tree
Hide file tree
Showing 3 changed files with 3 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

0 comments on commit dd91f63

Please sign in to comment.