Added Logging router
MODIFY
src/server/rest/v1/router/GlobalRouter.ts
src/server/rest/v1/router/GlobalRouter.ts
@@ -5,6 +5,7 @@ import AuthRouter from './auth/AuthRouter';
import AuthService from '../service/AuthService';
import BillingRouter from './api/BillingRouter';
import ChargingStationRouter from './api/ChargingStationRouter';
+import LoggingRouter from './api/LoggingRouter';
import { StatusCodes } from 'http-status-codes';
import SwaggerRouter from './doc/SwaggerRouter';
import TagRouter from './api/TagRouter';
@@ -38,13 +39,14 @@ export default class GlobalRouter {
AuthService.authenticate(),
AuthService.checkSessionHash.bind(this),
[
- new ChargingStationRouter().buildRoutes(),
new AssetRouter().buildRoutes(),
+ new BillingRouter().buildRoutes(),
+ new ChargingStationRouter().buildRoutes(),
+ new LoggingRouter().buildRoutes(),
new TagRouter().buildRoutes(),
new TenantRouter().buildRoutes(),
new TransactionRouter().buildRoutes(),
new UserRouter().buildRoutes(),
- new BillingRouter().buildRoutes(),
]);
}

ADD
src/server/rest/v1/router/api/LoggingRouter.ts
+/* eslint-disable @typescript-eslint/no-misused-promises */
+import { ServerAction, ServerRoute } from '../../../../../types/Server';
+import express, { NextFunction, Request, Response } from 'express';
+
+import LoggingService from '../../service/LoggingService';
+import RouterUtils from '../RouterUtils';
+
+export default class LoggingRouter {
+ private router: express.Router;
+
+ public constructor() {
+ this.router = express.Router();
+ }
+
+ public buildRoutes(): express.Router {
+ this.buildRouteLoggings();
+ this.buildRouteLogging();
+ this.buildRouteLoggingsExport();
+ return this.router;
+ }
+
+ protected buildRouteLoggings(): void {
+ this.router.get(`/${ServerRoute.REST_LOGGINGS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(LoggingService.handleGetLogs.bind(this), ServerAction.LOGGINGS, req, res, next);
+ });
+ }
+
+ protected buildRouteLogging(): void {
+ this.router.get(`/${ServerRoute.REST_LOGGING}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(LoggingService.handleGetLog.bind(this), ServerAction.LOGGING, req, res, next);
+ });
+ }
+
+ protected buildRouteLoggingsExport(): void {
+ this.router.get(`/${ServerRoute.REST_LOGGINGS_EXPORT}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(LoggingService.handleExportLogs.bind(this), ServerAction.LOGGINGS_EXPORT, req, res, next);
+ });
+ }
+}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -523,6 +523,10 @@ export enum ServerRoute {
REST_TENANTS = 'tenants',
REST_TENANT = 'tenants/:id',
+ REST_LOGGINGS = 'loggings',
+ REST_LOGGING = 'loggings/:id',
+ REST_LOGGINGS_EXPORT = 'loggings/action/export',
+
// BILLING URLs for CRUD operations on PAYMENT METHODS
REST_BILLING_PAYMENT_METHODS = 'users/:userID/payment-methods',
REST_BILLING_PAYMENT_METHOD = 'users/:userID/payment-methods/:paymentMethodID',

Added Logging router