Debug REST requests
MODIFY
package.json
package.json
"mongo-sanitize": "^1.1.0",
"mongo-uri-builder": "^3.2.2",
"mongodb": "^3.6.2",
+ "morgan": "^1.10.0",
"mustache": "^4.0.1",
"node-cron": "^2.0.3",
"passport": "^0.4.1",

MODIFY
src/server/ExpressTools.ts
src/server/ExpressTools.ts
@@ -18,11 +18,12 @@ import hpp from 'hpp';
import http from 'http';
import https from 'https';
import locale from 'locale';
+import morgan from 'morgan';
bodyParserXml(bodyParser);
export default class ExpressTools {
- public static initApplication(bodyLimit = '1mb'): express.Application {
+ public static initApplication(bodyLimit = '1mb', debug = false): express.Application {
const app = express();
// Secure the application
app.use(helmet());
@@ -36,6 +37,10 @@ export default class ExpressTools {
extended: false,
limit: bodyLimit
}));
+ // Debug
+ if (debug) {
+ app.use(morgan('tiny'));
+ }
app.use(hpp());
app.use(bodyParser['xml']({
limit: bodyLimit

MODIFY
src/server/ocpi/OCPIServer.ts
src/server/ocpi/OCPIServer.ts
@@ -2,23 +2,23 @@ import AbstractOCPIService, { TenantIdHoldingRequest } from './AbstractOCPIServi
import { Application, NextFunction, Request, Response } from 'express';
import CPOService from './ocpi-services-impl/ocpi-2.1.1/CPOService';
-import { Configuration } from '../../types/configuration/Configuration';
import EMSPService from './ocpi-services-impl/ocpi-2.1.1/EMSPService';
import ExpressTools from '../ExpressTools';
+import OCPIServiceConfiguration from '../../types/configuration/OCPIServiceConfiguration';
import OCPIServices from './OCPIServices';
const MODULE_NAME = 'OCPIServer';
export default class OCPIServer {
- private ocpiRestConfig: Configuration['OCPIService'];
+ private ocpiRestConfig: OCPIServiceConfiguration;
private expressApplication: Application;
// Create the rest server
- constructor(ocpiRestConfig: Configuration['OCPIService']) {
+ constructor(ocpiRestConfig: OCPIServiceConfiguration) {
// Keep params
this.ocpiRestConfig = ocpiRestConfig;
// Initialize express app
- this.expressApplication = ExpressTools.initApplication();
+ this.expressApplication = ExpressTools.initApplication(null, ocpiRestConfig.debug);
// New OCPI Services Instances
const ocpiServices = new OCPIServices(this.ocpiRestConfig);
// OCPI versions

MODIFY
src/server/ocpp/soap/SoapCentralSystemServer.ts
src/server/ocpp/soap/SoapCentralSystemServer.ts
@@ -26,7 +26,7 @@ export default class SoapCentralSystemServer extends CentralSystemServer {
// Call parent
super(centralSystemConfig, chargingStationConfig);
// Initialize express app
- this.expressApplication = ExpressTools.initApplication();
+ this.expressApplication = ExpressTools.initApplication(null, centralSystemConfig.debug);
// Initialize the HTTP server
this.httpServer = ExpressTools.createHttpServer(this.centralSystemConfig, this.expressApplication);
// Mount express-sanitizer middleware

MODIFY
src/server/odata/ODataServer.ts
src/server/odata/ODataServer.ts
@@ -18,7 +18,7 @@ export default class ODataServer {
// Keep params
this.oDataServerConfig = oDataServerConfig;
// Initialize express app
- this.expressApplication = ExpressTools.initApplication();
+ this.expressApplication = ExpressTools.initApplication(null, oDataServerConfig.debug);
// Get URL of the CentralSystemRestServer
const restConf = Configuration.getCentralSystemRestServer();
const restServerUrl = `${restConf.protocol}://${restConf.host}:${restConf.port}/`;

MODIFY
src/server/rest/CentralRestServer.ts
src/server/rest/CentralRestServer.ts
@@ -44,7 +44,7 @@ export default class CentralRestServer {
CentralRestServer.centralSystemRestConfig = centralSystemRestConfig;
this.chargingStationConfig = chargingStationConfig;
// Initialize express app
- this.expressApplication = ExpressTools.initApplication('2mb');
+ this.expressApplication = ExpressTools.initApplication('2mb', centralSystemRestConfig.debug);
// Mount express-sanitizer middleware
this.expressApplication.use(sanitize());
// Authentication

Debug REST requests