"spaced-comment": ["error", "always"],
"switch-colon-spacing": "error",
"arrow-body-style": ["error", "as-needed"],
- "arrow-parens": ["error", "always"],
+ "arrow-parens": ["error", "as-needed"],
"arrow-spacing": "error",
"no-duplicate-imports": "error",
"no-var": "error",
{
"printWidth": 100,
+ "arrowParens": "avoid",
"singleQuote": true
}
this.heartbeatSetInterval = setInterval(() => {
this.ocppRequestService
.requestHandler<HeartbeatRequest, HeartbeatResponse>(this, RequestCommand.HEARTBEAT)
- .catch((error) => {
+ .catch(error => {
logger.error(
`${this.logPrefix()} Error while sending '${RequestCommand.HEARTBEAT}':`,
error
meterValue: [meterValue],
}
)
- .catch((error) => {
+ .catch(error => {
logger.error(
`${this.logPrefix()} Error while sending '${RequestCommand.METER_VALUES}':`,
error
private flushMessageBuffer(): void {
if (this.messageBuffer.size > 0) {
- this.messageBuffer.forEach((message) => {
+ this.messageBuffer.forEach(message => {
let beginId: string;
let commandName: RequestCommand;
const [messageType] = JSON.parse(message) as OutgoingRequest | Response | ErrorResponse;
key: string | StandardParametersKey,
caseInsensitive = false
): ConfigurationKey | undefined {
- return chargingStation.ocppConfiguration.configurationKey.find((configElement) => {
+ return chargingStation.ocppConfiguration.configurationKey.find(configElement => {
if (caseInsensitive) {
return configElement.key.toLowerCase() === key.toLowerCase();
}
return hashId;
}
})
- .filter((hashId) => hashId !== undefined),
+ .filter(hashId => hashId !== undefined),
...(responsesStatus === ResponseStatus.FAILURE && {
hashIdsFailed: this.responses
.get(uuid)
return hashId;
}
})
- .filter((hashId) => hashId !== undefined),
+ .filter(hashId => hashId !== undefined),
}),
...(responsesStatus === ResponseStatus.FAILURE && {
responsesFailed: this.responses
.get(uuid)
- ?.responses.map((response) => {
+ ?.responses.map(response => {
if (response.status === ResponseStatus.FAILURE) {
return response;
}
})
- .filter((response) => response !== undefined),
+ .filter(response => response !== undefined),
}),
};
}
.getAuthorizedTags(
ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
)
- .find((idTag) => idTag === commandPayload.idTag)
+ .find(idTag => idTag === commandPayload.idTag)
) {
connectorStatus.localAuthorizeIdTag = commandPayload.idTag;
connectorStatus.idTagLocalAuthorized = true;
try {
const logFiles = fs
.readdirSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../'))
- .filter((file) => file.endsWith('.log'))
- .map((file) => path.join('./', file));
+ .filter(file => file.endsWith('.log'))
+ .map(file => path.join('./', file));
const diagnosticsArchive = `${chargingStation.stationInfo.chargingStationId}_logs.tar.gz`;
tar.create({ gzip: true }, logFiles).pipe(fs.createWriteStream(diagnosticsArchive));
ftpClient = new Client();
});
let uploadResponse: FTPResponse;
if (accessResponse.code === 220) {
- ftpClient.trackProgress((info) => {
+ ftpClient.trackProgress(info => {
logger.info(
`${chargingStation.logPrefix()} ${
info.bytes / 1024
>(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
status: OCPP16DiagnosticsStatus.Uploading,
})
- .catch((error) => {
+ .catch(error => {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION
chargingStation.bootNotificationRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
- .then((response) => {
+ .then(response => {
chargingStation.bootNotificationResponse = response;
})
.catch(() => {
.then(() => {
resolve(payload);
})
- .catch((error) => {
+ .catch(error => {
reject(error);
})
.finally(() => {
}
private requestListener(req: IncomingMessage, res: ServerResponse): void {
- this.authenticate(req, (err) => {
+ this.authenticate(req, err => {
if (err) {
res
.writeHead(StatusCodes.UNAUTHORIZED, {
throw new BaseError(`Unsupported UI protocol version: '${fullProtocol}'`);
}
this.registerProtocolVersionUIService(version);
- req.on('error', (error) => {
+ req.on('error', error => {
logger.error(
`${this.logPrefix(moduleName, 'requestListener.req.onerror')} Error on HTTP request:`,
error
if (req.method === 'POST') {
const bodyBuffer = [];
req
- .on('data', (chunk) => {
+ .on('data', chunk => {
bodyBuffer.push(chunk);
})
.on('end', () => {
}
const [, version] = UIServerUtils.getProtocolAndVersion(ws.protocol);
this.registerProtocolVersionUIService(version);
- ws.on('message', (rawData) => {
+ ws.on('message', rawData => {
const request = this.validateRawDataRequest(rawData);
if (request === false) {
ws.close(WebSocketCloseEventStatusCode.CLOSE_INVALID_PAYLOAD);
/* Error caught by AbstractUIService */
});
});
- ws.on('error', (error) => {
+ ws.on('error', error => {
logger.error(`${this.logPrefix(moduleName, 'start.ws.onerror')} WebSocket error:`, error);
});
ws.on('close', (code, reason) => {
this.httpServer.on(
'upgrade',
(req: IncomingMessage, socket: internal.Duplex, head: Buffer): void => {
- this.authenticate(req, (err) => {
+ this.authenticate(req, err => {
if (err) {
socket.write(`HTTP/1.1 ${StatusCodes.UNAUTHORIZED} Unauthorized\r\n\r\n`);
socket.destroy();
): void {
if (!Utils.isEmptyArray(payload.hashIds)) {
payload.hashIds = payload.hashIds
- .map((hashId) => {
+ .map(hashId => {
if (this.uiServer.chargingStations.has(hashId) === true) {
return hashId;
}
)} Charging station with hashId '${hashId}' not found`
);
})
- .filter((hashId) => hashId !== undefined);
+ .filter(hashId => hashId !== undefined);
}
const expectedNumberOfResponses = !Utils.isEmptyArray(payload.hashIds)
? payload.hashIds.length
}
private initializePerformanceObserver(): void {
- this.performanceObserver = new PerformanceObserver((performanceObserverList) => {
+ this.performanceObserver = new PerformanceObserver(performanceObserverList => {
const lastPerformanceEntry = performanceObserverList.getEntries()[0];
// logger.debug(
// `${this.logPrefix()} '${lastPerformanceEntry.name}' performance entry: %j`,
}
private extractTimeSeriesValues(timeSeries: CircularArray<TimeSeries>): number[] {
- return timeSeries.map((timeSeriesItem) => timeSeriesItem.value);
+ return timeSeries.map(timeSeriesItem => timeSeriesItem.value);
}
private logPrefix(): string {
this.checkPerformanceRecordsFile();
lockfile
.lock(this.dbName, { stale: 5000, retries: 3 })
- .then(async (release) => {
+ .then(async release => {
try {
const fileData = fs.readFileSync(this.dbName, 'utf8');
const performanceRecords: Statistics[] = fileData
Bootstrap.getInstance()
.start()
- .catch((error) => {
+ .catch(error => {
console.error(chalk.red(error));
});
// Nullify to force configuration file reading
Configuration.configuration = null;
if (!Configuration.isUndefined(Configuration.configurationChangeCallback)) {
- Configuration.configurationChangeCallback().catch((error) => {
+ Configuration.configurationChangeCallback().catch(error => {
throw typeof error === 'string' ? new Error(error) : error;
});
}
}
public static async sleep(milliSeconds: number): Promise<NodeJS.Timeout> {
- return new Promise((resolve) => setTimeout(resolve as () => void, milliSeconds));
+ return new Promise(resolve => setTimeout(resolve as () => void, milliSeconds));
}
public static formatDurationMilliSeconds(duration: number): string {
).bind(this) as MessageHandler<Worker>
);
worker.on('error', WorkerUtils.defaultErrorHandler.bind(this) as (err: Error) => void);
- worker.on('exit', (code) => {
+ worker.on('exit', code => {
WorkerUtils.defaultExitHandler(code);
this.workerSet.delete(this.getWorkerSetElementByWorker(worker));
});
config.uiServer.protocol
);
this._ws.onmessage = this.responseHandler.bind(this);
- this._ws.onerror = (errorEvent) => {
+ this._ws.onerror = errorEvent => {
console.error('WebSocket error: ', errorEvent);
};
- this._ws.onclose = (closeEvent) => {
+ this._ws.onclose = closeEvent => {
console.info('WebSocket closed: ', closeEvent);
};
}