Added Auth router
MODIFY
src/server/rest/router/GlobalRouter.ts
src/server/rest/router/GlobalRouter.ts
import CentralRestServerAuthentication from '../CentralRestServerAuthentication';
+import { authRouter } from './auth/AuthRouter';
import express from 'express';
-import { swaggerRouter } from './SwaggerRouter';
-import { tenantRouter } from './TenantRouter';
+import { swaggerRouter } from './doc/SwaggerRouter';
+import { tenantRouter } from './api/TenantRouter';
export const globalRouter = express.Router();
// API
globalRouter.use('/v1/api', CentralRestServerAuthentication.authenticate(), tenantRouter);
+// Auth
+globalRouter.use('/v1/auth', authRouter);
+
// Docs
globalRouter.use('/v1/docs', swaggerRouter);

RENAME
src/server/rest/router/TenantRouter.ts
src/server/rest/router/api/TenantRouter.ts
import express, { NextFunction, Request, Response } from 'express';
-import { ServerAction } from '../../../types/Server';
-import TenantService from '../service/TenantService';
+import { ServerAction } from '../../../../types/Server';
+import TenantService from '../../service/TenantService';
export const tenantRouter = express.Router();

ADD
src/server/rest/router/auth/AuthRouter.ts
+import express, { NextFunction, Request, Response } from 'express';
+
+import AuthService from '../../service/AuthService';
+import { ServerAction } from '../../../../types/Server';
+
+export const authRouter = express.Router();
+
+authRouter.post('/login', async (req: Request, res: Response, next: NextFunction) => {
+ try {
+ await AuthService.handleLogIn(ServerAction.LOGIN, req, res, next);
+ next();
+ } catch (error) {
+ next(error);
+ }
+});
+

RENAME
src/server/rest/router/SwaggerRouter.ts
src/server/rest/router/doc/SwaggerRouter.ts
import express, { NextFunction, Request, Response } from 'express';
import fs from 'fs';
-import global from '../../../types/GlobalType';
+import global from '../../../../types/GlobalType';
import swaggerUi from 'swagger-ui-express';
export const swaggerRouter = express.Router();

Added Auth router