Align Server class namings
MODIFY
src/client/ocpp/json/JsonChargingStationClient.ts
src/client/ocpp/json/JsonChargingStationClient.ts
@@ -2,7 +2,7 @@ import { OCPPCancelReservationRequest, OCPPCancelReservationResponse, OCPPChange
import ChargingStationClient from '../../ocpp/ChargingStationClient';
import { Command } from '../../../types/ChargingStation';
-import JsonWSConnection from '../../../server/ocpp/json/JsonWSConnection';
+import JsonWSConnection from '../../../server/ocpp/json/web-socket/JsonWSConnection';
import Logging from '../../../utils/Logging';
import { OCPPMessageType } from '../../../types/ocpp/OCPPCommon';
import OCPPUtils from '../../../server/ocpp/utils/OCPPUtils';

MODIFY
src/server/ocpi/OCPIServer.ts
src/server/ocpi/OCPIServer.ts
@@ -24,8 +24,8 @@ export default class OCPIServer {
this.ocpiRestConfig = ocpiRestConfig;
// Initialize express app
this.expressApplication = ExpressUtils.initApplication(null, ocpiRestConfig.debug);
- // Log Express Request
- this.expressApplication.use(this.resolveTenant.bind(this));
+ // Authenticate
+ this.expressApplication.use(this.initialize.bind(this));
// Log Express Request
this.expressApplication.use(Logging.traceExpressRequest.bind(this));
// New OCPI Services Instances
@@ -55,7 +55,7 @@ export default class OCPIServer {
ServerUtils.startHttpServer(this.ocpiRestConfig, ServerUtils.createHttpServer(this.ocpiRestConfig, this.expressApplication), MODULE_NAME, ServerType.OCPI_SERVER);
}
- private async resolveTenant(req: Request, res: Response, next: NextFunction): Promise<void> {
+ private async initialize(req: Request, res: Response, next: NextFunction): Promise<void> {
if (req.headers?.authorization?.startsWith('Token')) {
try {
if (req.headers?.authorization.startsWith('Token')) {

RENAME
src/server/ocpp/CentralSystemServer.ts
src/server/ocpp/OCPPServer.ts
@@ -3,13 +3,13 @@ import ChargingStationConfiguration from '../../types/configuration/ChargingStat
import OCPPService from './services/OCPPService';
import { OCPPVersion } from '../../types/ocpp/OCPPServer';
-export default abstract class CentralSystemServer {
+export default abstract class OCPPServer {
private static chargingStationService: OCPPService | null = null;
protected centralSystemConfig: CentralSystemConfiguration;
protected chargingStationConfig: ChargingStationConfiguration;
// Common constructor for Central System Server
- constructor(centralSystemConfig: CentralSystemConfiguration, chargingStationConfig: ChargingStationConfiguration) {
+ public constructor(centralSystemConfig: CentralSystemConfiguration, chargingStationConfig: ChargingStationConfiguration) {
// Init
this.centralSystemConfig = centralSystemConfig;
this.chargingStationConfig = chargingStationConfig;
@@ -20,10 +20,10 @@ export default abstract class CentralSystemServer {
case OCPPVersion.VERSION_15:
case OCPPVersion.VERSION_16:
default:
- if (!CentralSystemServer.chargingStationService) {
- CentralSystemServer.chargingStationService = new OCPPService(this.chargingStationConfig);
+ if (!OCPPServer.chargingStationService) {
+ OCPPServer.chargingStationService = new OCPPService(this.chargingStationConfig);
}
- return CentralSystemServer.chargingStationService;
+ return OCPPServer.chargingStationService;
}
}

RENAME
src/server/ocpp/json/JsonCentralSystemServer.ts
src/server/ocpp/json/JsonOCPPServer.ts
@@ -5,26 +5,26 @@ import { ServerAction, ServerType, WSServerProtocol } from '../../../types/Serve
import { WebSocketAction, WebSocketCloseEventStatusCode, WebSocketPingResult } from '../../../types/WebSocket';
import CentralSystemConfiguration from '../../../types/configuration/CentralSystemConfiguration';
-import CentralSystemServer from '../CentralSystemServer';
import ChargingStation from '../../../types/ChargingStation';
import ChargingStationClient from '../../../client/ocpp/ChargingStationClient';
import ChargingStationConfiguration from '../../../types/configuration/ChargingStationConfiguration';
import Configuration from '../../../utils/Configuration';
import Constants from '../../../utils/Constants';
-import JsonRestWSConnection from './JsonRestWSConnection';
-import JsonWSConnection from './JsonWSConnection';
+import JsonRestWSConnection from './web-socket/JsonRestWSConnection';
+import JsonWSConnection from './web-socket/JsonWSConnection';
import Logging from '../../../utils/Logging';
import LoggingHelper from '../../../utils/LoggingHelper';
import { OCPPMessageType } from '../../../types/ocpp/OCPPCommon';
+import OCPPServer from '../OCPPServer';
import Tenant from '../../../types/Tenant';
import Utils from '../../../utils/Utils';
-import WSConnection from './WSConnection';
-import WSWrapper from './WSWrapper';
+import WSConnection from './web-socket/WSConnection';
+import WSWrapper from './web-socket/WSWrapper';
import global from '../../../types/GlobalType';
-const MODULE_NAME = 'JsonCentralSystemServer';
+const MODULE_NAME = 'JsonOCPPServer';
-export default class JsonCentralSystemServer extends CentralSystemServer {
+export default class JsonOCPPServer extends OCPPServer {
private waitingWSMessages = 0;
private runningWSMessages = 0;
private runningWSRequestsMessages: Record<string, boolean> = {};

RENAME
src/server/ocpp/json/JsonRestWSConnection.ts
src/server/ocpp/json/web-socket/JsonRestWSConnection.ts
-import BackendError from '../../../exception/BackendError';
-import ChargingStationStorage from '../../../storage/mongodb/ChargingStationStorage';
-import { Command } from '../../../types/ChargingStation';
-import OCPPUtils from '../utils/OCPPUtils';
+import BackendError from '../../../../exception/BackendError';
+import ChargingStationStorage from '../../../../storage/mongodb/ChargingStationStorage';
+import { Command } from '../../../../types/ChargingStation';
+import OCPPUtils from '../../utils/OCPPUtils';
import WSConnection from './WSConnection';
import WSWrapper from './WSWrapper';
-import global from '../../../types/GlobalType';
+import global from '../../../../types/GlobalType';
const MODULE_NAME = 'JsonRestWSConnection';

RENAME
src/server/ocpp/json/JsonWSConnection.ts
src/server/ocpp/json/web-socket/JsonWSConnection.ts
-import ChargingStation, { Command } from '../../../types/ChargingStation';
-import { OCPPProtocol, OCPPVersion } from '../../../types/ocpp/OCPPServer';
+import ChargingStation, { Command } from '../../../../types/ChargingStation';
+import { OCPPProtocol, OCPPVersion } from '../../../../types/ocpp/OCPPServer';
-import BackendError from '../../../exception/BackendError';
-import ChargingStationClient from '../../../client/ocpp/ChargingStationClient';
-import ChargingStationStorage from '../../../storage/mongodb/ChargingStationStorage';
-import Configuration from '../../../utils/Configuration';
-import Constants from '../../../utils/Constants';
-import JsonChargingStationClient from '../../../client/ocpp/json/JsonChargingStationClient';
-import JsonChargingStationService from './services/JsonChargingStationService';
-import Logging from '../../../utils/Logging';
-import OCPPError from '../../../exception/OcppError';
-import { OCPPErrorType } from '../../../types/ocpp/OCPPCommon';
-import { OCPPHeader } from '../../../types/ocpp/OCPPHeader';
-import OCPPUtils from '../utils/OCPPUtils';
+import BackendError from '../../../../exception/BackendError';
+import ChargingStationClient from '../../../../client/ocpp/ChargingStationClient';
+import ChargingStationStorage from '../../../../storage/mongodb/ChargingStationStorage';
+import Configuration from '../../../../utils/Configuration';
+import Constants from '../../../../utils/Constants';
+import JsonChargingStationClient from '../../../../client/ocpp/json/JsonChargingStationClient';
+import JsonChargingStationService from '../services/JsonChargingStationService';
+import Logging from '../../../../utils/Logging';
+import OCPPError from '../../../../exception/OcppError';
+import { OCPPErrorType } from '../../../../types/ocpp/OCPPCommon';
+import { OCPPHeader } from '../../../../types/ocpp/OCPPHeader';
+import OCPPUtils from '../../utils/OCPPUtils';
import WSConnection from './WSConnection';
import WSWrapper from './WSWrapper';

RENAME
src/server/ocpp/json/WSConnection.ts
src/server/ocpp/json/web-socket/WSConnection.ts
-import ChargingStation, { Command } from '../../../types/ChargingStation';
-import { FctOCPPReject, FctOCPPResponse, OCPPErrorType, OCPPIncomingRequest, OCPPIncomingResponse, OCPPMessageType, OCPPRequest } from '../../../types/ocpp/OCPPCommon';
+import ChargingStation, { Command } from '../../../../types/ChargingStation';
+import { FctOCPPReject, FctOCPPResponse, OCPPErrorType, OCPPIncomingRequest, OCPPIncomingResponse, OCPPMessageType, OCPPRequest } from '../../../../types/ocpp/OCPPCommon';
-import BackendError from '../../../exception/BackendError';
-import Constants from '../../../utils/Constants';
-import Logging from '../../../utils/Logging';
-import OCPPError from '../../../exception/OcppError';
-import OCPPUtils from '../utils/OCPPUtils';
-import { ServerAction } from '../../../types/Server';
-import Tenant from '../../../types/Tenant';
-import Utils from '../../../utils/Utils';
+import BackendError from '../../../../exception/BackendError';
+import Constants from '../../../../utils/Constants';
+import Logging from '../../../../utils/Logging';
+import OCPPError from '../../../../exception/OcppError';
+import OCPPUtils from '../../utils/OCPPUtils';
+import { ServerAction } from '../../../../types/Server';
+import Tenant from '../../../../types/Tenant';
+import Utils from '../../../../utils/Utils';
import WSWrapper from './WSWrapper';
const MODULE_NAME = 'WSConnection';

RENAME
src/server/ocpp/json/WSWrapper.ts
src/server/ocpp/json/web-socket/WSWrapper.ts
import { RecognizedString, WebSocket } from 'uWebSockets.js';
-import Utils from '../../../utils/Utils';
+import Utils from '../../../../utils/Utils';
import WSConnection from './WSConnection';
-import { WSServerProtocol } from '../../../types/Server';
-import { WebSocketAction } from '../../../types/WebSocket';
+import { WSServerProtocol } from '../../../../types/Server';
+import { WebSocketAction } from '../../../../types/WebSocket';
export default class WSWrapper {
public key: string;

RENAME
src/server/ocpp/soap/SoapCentralSystemServer.ts
src/server/ocpp/soap/SoapOCPPServer.ts
import { ServerAction, ServerType } from '../../../types/Server';
import CentralSystemConfiguration from '../../../types/configuration/CentralSystemConfiguration';
-import CentralSystemServer from '../CentralSystemServer';
import ChargingStationConfiguration from '../../../types/configuration/ChargingStationConfiguration';
import Constants from '../../../utils/Constants';
import ExpressUtils from '../../ExpressUtils';
import Logging from '../../../utils/Logging';
+import OCPPServer from '../OCPPServer';
import { OCPPVersion } from '../../../types/ocpp/OCPPServer';
import { ServerUtils } from '../../ServerUtils';
import Utils from '../../../utils/Utils';
@@ -17,9 +17,9 @@ import global from '../../../types/GlobalType';
import http from 'http';
import { soap } from 'strong-soap';
-const MODULE_NAME = 'SoapCentralSystemServer';
+const MODULE_NAME = 'SoapOCPPServer';
-export default class SoapCentralSystemServer extends CentralSystemServer {
+export default class SoapOCPPServer extends OCPPServer {
public httpServer: http.Server;
private expressApplication: express.Application;

RENAME
src/server/rest/CentralRestServer.ts
src/server/rest/RestServer.ts
import { Application, NextFunction, Request, Response } from 'express';
import AuthService from './v1/service/AuthService';
-import CentralRestServerService from './CentralRestServerService';
import CentralSystemRestServiceConfiguration from '../../types/configuration/CentralSystemRestServiceConfiguration';
import ExpressUtils from '../ExpressUtils';
import GlobalRouter from './v1/router/GlobalRouter';
import Logging from '../../utils/Logging';
+import RestServerService from './RestServerService';
import { ServerType } from '../../types/Server';
import { ServerUtils } from '../ServerUtils';
import SessionHashService from './v1/service/SessionHashService';
import http from 'http';
-const MODULE_NAME = 'CentralRestServer';
+const MODULE_NAME = 'RestServer';
-export default class CentralRestServer {
+export default class RestServer {
private static centralSystemRestConfig: CentralSystemRestServiceConfiguration;
private static restHttpServer: http.Server;
private expressApplication: Application;
@@ -21,7 +21,7 @@ export default class CentralRestServer {
// Create the rest server
public constructor(centralSystemRestConfig: CentralSystemRestServiceConfiguration) {
// Keep params
- CentralRestServer.centralSystemRestConfig = centralSystemRestConfig;
+ RestServer.centralSystemRestConfig = centralSystemRestConfig;
// Initialize express app
this.expressApplication = ExpressUtils.initApplication('1mb', centralSystemRestConfig.debug);
// Authentication
@@ -33,20 +33,20 @@ export default class CentralRestServer {
AuthService.authenticate(),
SessionHashService.checkUserAndTenantValidity.bind(this),
Logging.traceExpressRequest.bind(this),
- CentralRestServerService.restServiceSecured.bind(this)
+ RestServerService.restServiceSecured.bind(this)
);
// Util API
this.expressApplication.use('/client/util/:action',
Logging.traceExpressRequest.bind(this),
- CentralRestServerService.restServiceUtil.bind(this)
+ RestServerService.restServiceUtil.bind(this)
);
// Post init
ExpressUtils.postInitApplication(this.expressApplication);
// Create HTTP server to serve the express app
- CentralRestServer.restHttpServer = ServerUtils.createHttpServer(CentralRestServer.centralSystemRestConfig, this.expressApplication);
+ RestServer.restHttpServer = ServerUtils.createHttpServer(RestServer.centralSystemRestConfig, this.expressApplication);
}
public start(): void {
- ServerUtils.startHttpServer(CentralRestServer.centralSystemRestConfig, CentralRestServer.restHttpServer, MODULE_NAME, ServerType.REST_SERVER);
+ ServerUtils.startHttpServer(RestServer.centralSystemRestConfig, RestServer.restHttpServer, MODULE_NAME, ServerType.REST_SERVER);
}
}

RENAME
src/server/rest/CentralRestServerService.ts
src/server/rest/RestServerService.ts
@@ -245,7 +245,7 @@ class RequestMapper {
}
}
-export default class CentralRestServerService {
+export default class RestServerService {
// Util Service
public static async restServiceUtil(req: Request, res: Response, next: NextFunction): Promise<void> {
try {

MODIFY
src/start.ts
src/start.ts
@@ -3,14 +3,13 @@ import { ServerAction, ServerType } from './types/Server';
import AsyncTaskConfiguration from './types/configuration/AsyncTaskConfiguration';
import AsyncTaskManager from './async-task/AsyncTaskManager';
-import CentralRestServer from './server/rest/CentralRestServer';
import CentralSystemRestServiceConfiguration from './types/configuration/CentralSystemRestServiceConfiguration';
import ChargingStationConfiguration from './types/configuration/ChargingStationConfiguration';
import ChargingStationTemplateBootstrap from './bootstrap/ChargingStationTemplateBootstrap';
import Configuration from './utils/Configuration';
import Constants from './utils/Constants';
import I18nManager from './utils/I18nManager';
-import JsonCentralSystemServer from './server/ocpp/json/JsonCentralSystemServer';
+import JsonOCPPServer from './server/ocpp/json/JsonOCPPServer';
import LocalCarCatalogBootstrap from './bootstrap/LocalCarCatalogBootstrap';
import Logging from './utils/Logging';
import MigrationConfiguration from './types/configuration/MigrationConfiguration';
@@ -25,9 +24,10 @@ import ODataServer from './server/odata/ODataServer';
import ODataServiceConfiguration from './types/configuration/ODataServiceConfiguration';
import OICPServer from './server/oicp/OICPServer';
import OICPServiceConfiguration from './types/configuration/OICPServiceConfiguration';
+import RestServer from './server/rest/RestServer';
import SchedulerConfiguration from './types/configuration/SchedulerConfiguration';
import SchedulerManager from './scheduler/SchedulerManager';
-import SoapCentralSystemServer from './server/ocpp/soap/SoapCentralSystemServer';
+import SoapOCPPServer from './server/ocpp/soap/SoapOCPPServer';
import StorageConfiguration from './types/configuration/StorageConfiguration';
import Utils from './utils/Utils';
import global from './types/GlobalType';
@@ -37,10 +37,10 @@ const MODULE_NAME = 'Bootstrap';
export default class Bootstrap {
private static database: MongoDBStorage;
- private static centralRestServer: CentralRestServer;
+ private static centralRestServer: RestServer;
private static storageConfig: StorageConfiguration;
- private static SoapCentralSystemServer: SoapCentralSystemServer;
- private static JsonCentralSystemServer: JsonCentralSystemServer;
+ private static SoapCentralSystemServer: SoapOCPPServer;
+ private static JsonCentralSystemServer: JsonOCPPServer;
private static ocpiServer: OCPIServer;
private static oicpServer: OICPServer;
private static oDataServer: ODataServer;
@@ -241,7 +241,7 @@ export default class Bootstrap {
if (Bootstrap.centralSystemRestConfig) {
// Create the server
if (!Bootstrap.centralRestServer) {
- Bootstrap.centralRestServer = new CentralRestServer(Bootstrap.centralSystemRestConfig);
+ Bootstrap.centralRestServer = new RestServer(Bootstrap.centralSystemRestConfig);
}
// Start it
Bootstrap.centralRestServer.start();
@@ -258,14 +258,14 @@ export default class Bootstrap {
// SOAP
case CentralSystemImplementation.SOAP:
// Create implementation
- Bootstrap.SoapCentralSystemServer = new SoapCentralSystemServer(centralSystemConfig, Bootstrap.chargingStationConfig);
+ Bootstrap.SoapCentralSystemServer = new SoapOCPPServer(centralSystemConfig, Bootstrap.chargingStationConfig);
// Start
Bootstrap.SoapCentralSystemServer.start();
serverTypes.push(ServerType.SOAP_SERVER);
break;
case CentralSystemImplementation.JSON:
// Create implementation
- Bootstrap.JsonCentralSystemServer = new JsonCentralSystemServer(centralSystemConfig, Bootstrap.chargingStationConfig);
+ Bootstrap.JsonCentralSystemServer = new JsonOCPPServer(centralSystemConfig, Bootstrap.chargingStationConfig);
// Start
Bootstrap.JsonCentralSystemServer.start();
serverTypes.push(ServerType.JSON_SERVER);

MODIFY
src/types/GlobalType.ts
src/types/GlobalType.ts
@@ -2,7 +2,7 @@ import { Car, CarCatalog } from './Car';
import ChargingStation from './ChargingStation';
import Company from './Company';
-import JsonCentralSystemServer from '../server/ocpp/json/JsonCentralSystemServer';
+import JsonOCPPServer from '../server/ocpp/json/JsonOCPPServer';
import { Log } from './Log';
import MongoDBStorage from '../storage/mongodb/MongoDBStorage';
import PricingDefinition from './Pricing';
@@ -10,7 +10,7 @@ import RegistrationToken from './RegistrationToken';
import { ServerType } from './Server';
import Site from './Site';
import SiteArea from './SiteArea';
-import SoapCentralSystemServer from '../server/ocpp/soap/SoapCentralSystemServer';
+import SoapOCPPServer from '../server/ocpp/soap/SoapOCPPServer';
import Tag from './Tag';
import User from './User';
import bluebird from 'bluebird';
@@ -79,8 +79,8 @@ export type EntityData = Car|User|Company|Site|SiteArea|Tag|CarCatalog|ChargingS
interface TSGlobal extends Global {
database: MongoDBStorage;
appRoot: string;
- centralSystemJsonServer: JsonCentralSystemServer;
- centralSystemSoapServer: SoapCentralSystemServer;
+ centralSystemJsonServer: JsonOCPPServer;
+ centralSystemSoapServer: SoapOCPPServer;
serverType: ServerType;
Promise: any;
}

MODIFY
src/utils/LoggingHelper.ts
src/utils/LoggingHelper.ts
@@ -7,7 +7,7 @@ import SiteArea from '../types/SiteArea';
import Tag from '../types/Tag';
import Transaction from '../types/Transaction';
import User from '../types/User';
-import WSWrapper from '../server/ocpp/json/WSWrapper';
+import WSWrapper from '../server/ocpp/json/web-socket/WSWrapper';
export default class LoggingHelper {

Align Server class namings