Skip to content

Commit 89fc776

Browse files
author
Artem
authored
Merge pull request #2810 from RedisInsight/be/feature/RI-5036/optimize-docker-image-review-fix
fix comments add tests
2 parents 0912568 + 29df335 commit 89fc776

File tree

5 files changed

+50
-4
lines changed

5 files changed

+50
-4
lines changed

redisinsight/api/config/default.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export default {
4040
},
4141
server: {
4242
version,
43-
env: 'development',
43+
env: process.env.NODE_ENV || 'development',
4444
host: process.env.RI_APP_HOST ?? '0.0.0.0',
45-
port: parseInt(process.env.RI_APP_PORT, 10) ?? 5000,
45+
port: parseInt(process.env.RI_APP_PORT, 10) || 5000,
4646
docPrefix: 'api/docs',
4747
globalPrefix: 'api',
4848
customPluginsUri: '/plugins',

redisinsight/api/config/development.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
export default {
2+
server: {
3+
env: 'development',
4+
},
25
sockets: {
36
cors: true,
47
},

redisinsight/api/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs';
22
import {
3-
MiddlewareConsumer, Module, NestModule, OnModuleInit
3+
MiddlewareConsumer, Module, NestModule, OnModuleInit,
44
} from '@nestjs/common';
55
import { ServeStaticModule } from '@nestjs/serve-static';
66
import { RouterModule } from 'nest-router';

redisinsight/api/src/modules/server/server.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
mockServerRepository,
1212
MockType,
1313
} from 'src/__mocks__';
14-
import config from 'src/utils/config';
14+
import config, { Config } from 'src/utils/config';
1515
import {
1616
ServerInfoNotFoundException,
1717
AppAnalyticsEvents,

redisinsight/api/src/utils/config.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import { Config } from 'src/utils/config';
2+
import { merge } from 'lodash';
13
import defaultConfig from '../../config/default';
24
import devConfig from '../../config/development';
5+
import testConfig from '../../config/test';
36
import stageConfig from '../../config/staging';
47
import prodConfig from '../../config/production';
8+
import stackConfig from '../../config/stack';
59

610
describe('Config util', () => {
711
const OLD_ENV = process.env;
@@ -32,6 +36,35 @@ describe('Config util', () => {
3236
});
3337
});
3438

39+
it('should return test server config', () => {
40+
process.env.NODE_ENV = 'test';
41+
// eslint-disable-next-line global-require
42+
const { get } = require('./config');
43+
44+
const result = get('server') as Config['server'];
45+
46+
expect(result).toEqual({
47+
...defaultConfig.server,
48+
...testConfig.server,
49+
});
50+
});
51+
52+
it('should return stack server config', () => {
53+
process.env.BUILD_TYPE = 'REDIS_STACK';
54+
process.env.NODE_ENV = 'staging';
55+
// eslint-disable-next-line global-require
56+
const { get } = require('./config');
57+
58+
const result = get('server') as Config['server'];
59+
60+
expect(result).toEqual({
61+
...defaultConfig.server,
62+
...stageConfig.server,
63+
...stackConfig.server,
64+
buildType: 'REDIS_STACK',
65+
});
66+
});
67+
3568
it('should return stage server config', () => {
3669
process.env.NODE_ENV = 'staging';
3770
// eslint-disable-next-line global-require
@@ -57,5 +90,15 @@ describe('Config util', () => {
5790
...prodConfig.server,
5891
});
5992
});
93+
94+
it('should return entire prod server config', () => {
95+
process.env.NODE_ENV = 'production';
96+
// eslint-disable-next-line global-require
97+
const { get } = require('./config');
98+
99+
const result = get() as Config['server'];
100+
101+
expect(result).toEqual(merge({ ...defaultConfig }, { ...prodConfig }));
102+
});
60103
});
61104
});

0 commit comments

Comments
 (0)