Check K8s configuration
MODIFY
src/start.ts
src/start.ts
@@ -116,10 +116,7 @@ export default class Bootstrap {
// -------------------------------------------------------------------------
// Start all the Servers
// -------------------------------------------------------------------------
- startTimeMillis = await this.logAndGetStartTimeMillis('Server is starting...');
- // Start the Servers
- serverStarted = await Bootstrap.startServersListening();
- await this.logDuration(startTimeMillis, `Server ${serverStarted.join(', ')} has been started successfully`);
+ serverStarted = await Bootstrap.startServers();
// -------------------------------------------------------------------------
// Init the Scheduler
@@ -207,7 +204,7 @@ export default class Bootstrap {
}
}
- private static async startServersListening(): Promise<ServerType[]> {
+ private static async startServers(): Promise<ServerType[]> {
const serverTypes: ServerType[] = [];
try {
// -------------------------------------------------------------------------

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -142,8 +142,7 @@ export default class CarStorage {
public static async saveCarCatalog(carToSave: CarCatalog): Promise<number> {
const startTime = Logging.traceDatabaseRequestStart();
// Validate
- const carCatalog = CarValidatorStorage.getInstance().validateCarCatalog(
- carToSave as unknown as Record<string, unknown>);
+ const carCatalog = CarValidatorStorage.getInstance().validateCarCatalog(carToSave);
// Properties to save
const carMDB: any = {
_id: carToSave.id,

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -84,8 +84,7 @@ export default class ChargingStationStorage {
public static async saveChargingStationTemplate(chargingStationTemplate: ChargingStationTemplate): Promise<void> {
const startTime = Logging.traceDatabaseRequestStart();
// Validate
- chargingStationTemplate = ChargingStationValidatorStorage.getInstance().validateChargingStationTemplate(
- chargingStationTemplate as unknown as Record<string, unknown>);
+ chargingStationTemplate = ChargingStationValidatorStorage.getInstance().validateChargingStationTemplate(chargingStationTemplate);
// Modify and return the modified document
await global.database.getCollection<ChargingStationTemplate>(Constants.DEFAULT_TENANT, 'chargingstationtemplates').findOneAndReplace(
{ '_id': chargingStationTemplate.id },

MODIFY
src/storage/mongodb/PerformanceStorage.ts
src/storage/mongodb/PerformanceStorage.ts
@@ -14,8 +14,7 @@ export default class PerformanceStorage {
delete performanceRecord.tenantSubdomain;
}
// Validate
- performanceRecord = PerformanceValidatorStorage.getInstance().validatePerformance(
- performanceRecord as unknown as Record<string, unknown>);
+ performanceRecord = PerformanceValidatorStorage.getInstance().validatePerformance(performanceRecord);
// Insert
const result = await global.database.getCollection(Constants.DEFAULT_TENANT, 'performances')
.insertOne(performanceRecord);
@@ -26,8 +25,7 @@ export default class PerformanceStorage {
public static async updatePerformanceRecord(performanceRecord: PerformanceRecord): Promise<void> {
// Validate
- performanceRecord = PerformanceValidatorStorage.getInstance().validatePerformance(
- performanceRecord as unknown as Record<string, unknown>);
+ performanceRecord = PerformanceValidatorStorage.getInstance().validatePerformance(performanceRecord);
// Convert to ObjectID
performanceRecord['_id'] = DatabaseUtils.convertToObjectID(performanceRecord.id);
delete performanceRecord.id;

MODIFY
src/storage/mongodb/validator/AuthorizationValidatorStorage.ts
src/storage/mongodb/validator/AuthorizationValidatorStorage.ts
@@ -27,7 +27,7 @@ export default class AuthorizationValidatorStorage extends SchemaValidator {
return AuthorizationValidatorStorage.instance;
}
- public validateAuthorizationDefinitionRole(data: Record<string, unknown>): AuthorizationDefinitionRole {
+ public validateAuthorizationDefinitionRole(data: any): AuthorizationDefinitionRole {
return this.validate(this.authorizationRole, data);
}
}

MODIFY
src/storage/mongodb/validator/CarValidatorStorage.ts
src/storage/mongodb/validator/CarValidatorStorage.ts
@@ -27,7 +27,7 @@ export default class CarValidatorStorage extends SchemaValidator {
return CarValidatorStorage.instance;
}
- public validateCarCatalog(data: Record<string, unknown>): ChargingStationTemplate {
+ public validateCarCatalog(data: any): ChargingStationTemplate {
return this.validate(this.carCatalog, data);
}
}

MODIFY
src/storage/mongodb/validator/ChargingStationValidatorStorage.ts
src/storage/mongodb/validator/ChargingStationValidatorStorage.ts
@@ -27,7 +27,7 @@ export default class ChargingStationValidatorStorage extends SchemaValidator {
return ChargingStationValidatorStorage.instance;
}
- public validateChargingStationTemplate(data: Record<string, unknown>): ChargingStationTemplate {
+ public validateChargingStationTemplate(data: any): ChargingStationTemplate {
return this.validate(this.chargingStationTemplate, data);
}
}

MODIFY
src/storage/mongodb/validator/ConfigurationValidatorStorage.ts
src/storage/mongodb/validator/ConfigurationValidatorStorage.ts
@@ -27,7 +27,7 @@ export default class ConfigurationValidatorStorage extends SchemaValidator {
return ConfigurationValidatorStorage.instance;
}
- public validateConfiguration(data: Record<string, unknown>): Configuration {
+ public validateConfiguration(data: any): Configuration {
return this.validate(this.configuration, data);
}
}

MODIFY
src/storage/mongodb/validator/PerformanceValidatorStorage.ts
src/storage/mongodb/validator/PerformanceValidatorStorage.ts
@@ -27,7 +27,7 @@ export default class PerformanceValidatorStorage extends SchemaValidator {
return PerformanceValidatorStorage.instance;
}
- public validatePerformance(data: Record<string, unknown>): PerformanceRecord {
+ public validatePerformance(data: any): PerformanceRecord {
return this.validate(this.performance, data);
}
}

MODIFY
src/utils/Configuration.ts
src/utils/Configuration.ts
@@ -235,17 +235,18 @@ export default class Configuration {
private static getConfig(): ConfigurationData {
if (!Configuration.config) {
- const fileExists = fs.existsSync('/config/config.json');
- console.log('fileExists', fileExists);
- if (fileExists) {
- console.log(fs.readFileSync('/config/config.json', 'utf8'));
- }
- console.log('POD_NAME', process.env.POD_NAME);
- console.log('POD_NAMESPACE', process.env.POD_NAMESPACE);
- console.log('POD_IP', process.env.POD_IP);
- const config = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/config.json`, 'utf8')) as ConfigurationData;
- Configuration.config = ConfigurationValidatorStorage.getInstance().validateConfiguration(
- config as unknown as Record<string, unknown>);
+ let configuration: ConfigurationData;
+ // K8s
+ if (fs.existsSync('/config/config.json')) {
+ configuration = JSON.parse(
+ fs.readFileSync('/config/config.json', 'utf8')) as ConfigurationData;
+ // AWS
+ } else {
+ configuration = JSON.parse(
+ fs.readFileSync(`${global.appRoot}/assets/config.json`, 'utf8')) as ConfigurationData;
+ }
+ // Validate
+ Configuration.config = ConfigurationValidatorStorage.getInstance().validateConfiguration(configuration);
}
return Configuration.config;
}

Check K8s configuration