mirror of
https://github.com/immich-app/immich.git
synced 2026-03-06 18:17:27 +03:00
refactor(server): telemetry ports env (#13560)
This commit is contained in:
@@ -9,6 +9,9 @@ const resetEnv = () => {
|
||||
for (const env of [
|
||||
'IMMICH_WORKERS_INCLUDE',
|
||||
'IMMICH_WORKERS_EXCLUDE',
|
||||
'IMMICH_TRUSTED_PROXIES',
|
||||
'IMMICH_API_METRICS_PORT',
|
||||
'IMMICH_MICROSERVICES_METRICS_PORT',
|
||||
|
||||
'DB_URL',
|
||||
'DB_HOSTNAME',
|
||||
@@ -178,4 +181,41 @@ describe('getEnv', () => {
|
||||
expect(getEnv).toThrowError('Invalid worker(s) found: api,microservices,randomservice');
|
||||
});
|
||||
});
|
||||
|
||||
describe('network', () => {
|
||||
it('should return default network options', () => {
|
||||
const { network } = getEnv();
|
||||
expect(network).toEqual({
|
||||
trustedProxies: [],
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse trusted proxies', () => {
|
||||
process.env.IMMICH_TRUSTED_PROXIES = '10.1.0.0,10.2.0.0, 169.254.0.0/16';
|
||||
const { network } = getEnv();
|
||||
expect(network).toEqual({
|
||||
trustedProxies: ['10.1.0.0', '10.2.0.0', '169.254.0.0/16'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('telemetry', () => {
|
||||
it('should return default ports', () => {
|
||||
const { telemetry } = getEnv();
|
||||
expect(telemetry).toEqual({
|
||||
apiPort: 8081,
|
||||
microservicesPort: 8082,
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse custom ports', () => {
|
||||
process.env.IMMICH_API_METRICS_PORT = '2001';
|
||||
process.env.IMMICH_MICROSERVICES_METRICS_PORT = '2002';
|
||||
const { telemetry } = getEnv();
|
||||
expect(telemetry).toEqual({
|
||||
apiPort: 2001,
|
||||
microservicesPort: 2002,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user