GitLab wurde erfolgreich aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Danke für Ihre Geduld.

Updates the routes to use relative paths and use docker vars in the environment

parent 2874eb5b
......@@ -3,17 +3,14 @@ import * as bodyParser from 'body-parser';
import * as compress from 'compression';
import * as cors from 'cors';
import * as express from 'express';
import { Request, Response, Router } from 'express';
import { Router } from 'express';
import * as promBundle from 'express-prom-bundle';
import * as process from 'process';
import { collectDefaultMetrics, Counter } from 'prom-client';
import * as gcStats from 'prometheus-gc-stats';
import * as routeCache from 'route-cache';
import { RoutingControllersOptions, useExpressServer } from 'routing-controllers';
import * as swaggerUi from 'swagger-ui-express';
import * as timesyncServer from 'timesync/server';
import { dynamicStatistics } from './dynamic-statistics';
import { RoutingCache } from './enums/RoutingCache';
import options from './lib/cors.config';
import { ErrorHandlerMiddleware } from './routers/middleware/customErrorHandler';
import { I18nMiddleware } from './routers/middleware/i18n';
......@@ -30,7 +27,7 @@ import { QuizPoolRouter } from './routers/rest/QuizPoolRouter';
import { QuizRouter } from './routers/rest/QuizRouter';
import { TwitterRouter } from './routers/rest/TwitterRouter';
import LoggerService from './services/LoggerService';
import { publicSettings, settings } from './statistics';
import { settings } from './statistics';
export const routingControllerOptions: RoutingControllersOptions = {
defaults: {
......@@ -140,10 +137,6 @@ class App {
}));
const router: Router = express.Router();
router.get(`/statistics`, cors(options), routeCache.cacheSeconds(10, RoutingCache.Statistics), async (req: Request, res: Response) => {
res.send({...publicSettings, ...await dynamicStatistics()});
});
this._express.use(`/`, router);
}
......
......@@ -31,6 +31,7 @@ import CasDAO from '../../db/CasDAO';
import MathjaxDAO from '../../db/MathjaxDAO';
import QuizDAO from '../../db/QuizDAO';
import UserDAO from '../../db/UserDAO';
import { dynamicStatistics } from '../../dynamic-statistics';
import { MessageProtocol, StatusProtocol } from '../../enums/Message';
import { RoutingCache } from '../../enums/RoutingCache';
import { IMessage } from '../../interfaces/communication/IMessage';
......@@ -41,7 +42,7 @@ import { TwitterCard } from '../../lib/social-media/twitter/twitter-card';
import { UserModelItem } from '../../models/UserModelItem/UserModel';
import { AuthService } from '../../services/AuthService';
import LoggerService from '../../services/LoggerService';
import { settings } from '../../statistics';
import { publicSettings, settings } from '../../statistics';
import { AbstractRouter } from './AbstractRouter';
const casSettings = { base_url: 'https://cas.thm.de/cas' };
......@@ -104,6 +105,12 @@ export class LibRouter extends AbstractRouter {
};
}
@Get('/statistics')
@UseBefore(routeCache.cacheSeconds(10, RoutingCache.Statistics))
public async getStatistics(): Promise<object> {
return {...publicSettings, ...await dynamicStatistics()};
}
@Get('/mathjax/example/first')
public getFirstMathjaxExample(): object {
return new Promise<object>((resolve, reject) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment