Skip to content

Commit 52ae447

Browse files
committed
compact the code a bit
1 parent 3c3e00c commit 52ae447

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

src/routes/proxy/index.ts

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,19 @@ router.all('/common-services/**', async (req, res) => {
151151
status: 'active',
152152
authType: 'service-to-service',
153153
endpoint: config.get<string>('commonServices.url'),
154-
settings: {
155-
authTargetUrl: config.get<string>('commonServices.authUrl'),
156-
apiClientId: config.get<string>('commonServices.clientId'),
157-
scope: config.get<string>('commonServices.scope'),
158-
secret: config.get<string>('commonServices.clientSecret'),
159-
},
160-
};
161-
162-
//encrypt settings
163-
const settings = {
164-
authTargetUrl: commonServiceConfig.settings.authTargetUrl,
165-
apiClientID: commonServiceConfig.settings.apiClientId,
166-
scope: commonServiceConfig.settings.scope,
167-
safeSecret: commonServiceConfig.settings.secret,
168-
};
169-
const encryptedSettings = CryptoJS.AES.encrypt(
170-
JSON.stringify(settings),
171-
config.get('encryption.key')
172-
).toString();
173-
174-
//save common service config
175-
const commonServiceConfigToSave = {
176-
...commonServiceConfig,
177-
settings: encryptedSettings,
154+
settings: CryptoJS.AES.encrypt(
155+
JSON.stringify({
156+
authTargetUrl: config.get<string>('commonServices.authUrl'),
157+
apiClientID: config.get<string>('commonServices.clientId'),
158+
scope: config.get<string>('commonServices.scope'),
159+
safeSecret: config.get<string>('commonServices.clientSecret'),
160+
}),
161+
config.get('encryption.key')
162+
).toString(),
178163
};
179164

180165
try {
181-
const api = new ApiConfiguration(commonServiceConfigToSave);
166+
const api = new ApiConfiguration(commonServiceConfig);
182167
const path = req.originalUrl.split('common-services').pop().substring(1);
183168
await proxyAPIRequest(req, res, api, path);
184169
} catch (err) {

0 commit comments

Comments
 (0)