Return valited settings as SettingDB
MODIFY
src/server/rest/v1/service/SettingService.ts
src/server/rest/v1/service/SettingService.ts
@@ -151,7 +151,7 @@ export default class SettingService {
});
}
// Filter
- const filteredRequest = SettingService.filterSetting(action, req) as SettingDB;
+ const filteredRequest = SettingService.filterSetting(action, req);
// Process the sensitive data if any
await Cypher.encryptSensitiveDataInJSON(req.tenant, filteredRequest);
// Update timestamp
@@ -173,7 +173,7 @@ export default class SettingService {
public static async handleUpdateSetting(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
UtilsService.assertIdIsProvided(action, req.body.id, MODULE_NAME, 'handleUpdateSetting', req.user);
- const filteredRequest = SettingService.filterSetting(action, req) as SettingDB;
+ const filteredRequest = SettingService.filterSetting(action, req);
// Check auth
if (!await Authorizations.canUpdateSetting(req.user)) {
throw new AppAuthError({
@@ -296,7 +296,7 @@ export default class SettingService {
next();
}
- private static filterSetting(action: ServerAction, req: Request) {
+ private static filterSetting(action: ServerAction, req: Request): SettingDB {
switch (req.body.identifier) {
// Filter
case IntegrationSettings.OCPI:

MODIFY
src/server/rest/v1/validator/SettingValidator.ts
src/server/rest/v1/validator/SettingValidator.ts
@@ -2,6 +2,7 @@ import { HttpSettingAssetSetRequest, HttpSettingBillingSetRequest, HttpSettingCa
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from '../../../../validator/SchemaValidator';
+import { SettingDB } from '../../../../types/Setting';
import fs from 'fs';
import global from '../../../../types/GlobalType';
@@ -47,59 +48,59 @@ export default class SettingValidator extends SchemaValidator {
return SettingValidator.instance;
}
- public validateSettingOCPISetReq(data: Record<string, unknown>): HttpSettingOCPISetRequest {
+ public validateSettingOCPISetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingOCPISet, data);
}
- public validateSettingUserSetReq(data: Record<string, unknown>): HttpSettingUserSetRequest {
+ public validateSettingUserSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingUserSet, data);
}
- public validateSettingSmartChargingSetReq(data: Record<string, unknown>): HttpSettingSmartChargingSetRequest {
+ public validateSettingSmartChargingSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingSmartChargingSet, data);
}
- public validateSettingRefundSetReq(data: Record<string, unknown>): HttpSettingRefundSetRequest {
+ public validateSettingRefundSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingRefundSet, data);
}
- public validateSettingPricingSetReq(data: Record<string, unknown>): HttpSettingPricingSetRequest {
+ public validateSettingPricingSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingPricingSet, data);
}
- public validateSettingCryptoSetReq(data: Record<string, unknown>): HttpSettingCryptoSetRequest {
+ public validateSettingCryptoSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingCryptoSet, data);
}
- public validateSettingAnalyticsSetReq(data: Record<string, unknown>): HttpSettingSacSetRequest {
+ public validateSettingAnalyticsSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingAnalyticsSet, data);
}
- public validateSettingOICPSetReq(data: Record<string, unknown>): HttpSettingOICPSetRequest {
+ public validateSettingOICPSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingOICPSet, data);
}
- public validateSettingBillingSetReq(data: Record<string, unknown>): HttpSettingBillingSetRequest {
+ public validateSettingBillingSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingBillingSet, data);
}
- public validateSettingAssetSetReq(data: Record<string, unknown>): HttpSettingAssetSetRequest {
+ public validateSettingAssetSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingAssetSet, data);
}
- public validateSettingCarConnectorSetReq(data: Record<string, unknown>): HttpSettingCarConnectorSetRequest {
+ public validateSettingCarConnectorSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingCarConnectorSet, data);
}
- public validateSettingCarSetReq(data: Record<string, unknown>) {
+ public validateSettingCarSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingCarSet, data);
}
- public validateSettingOrganizationSetReq(data: Record<string, unknown>) {
+ public validateSettingOrganizationSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingOrganizationSet, data);
}
- public validateSettingStatisticsSetReq(data: Record<string, unknown>) {
+ public validateSettingStatisticsSetReq(data: Record<string, unknown>): SettingDB {
return this.validate(this.settingStatisticsSet, data);
}
}

Return valited settings as SettingDB