Skip to content

Commit

Permalink
cleanup imports, renamed function
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Afro committed Dec 16, 2024
1 parent ab5050c commit ce87e6d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 39 deletions.
4 changes: 2 additions & 2 deletions apps/server/src/apps/admin-api-server.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LegacyLogger, Logger } from '@src/core/logger';
import { AdminApiServerModule } from '@modules/server/admin-api.server.module';
import express from 'express';
import { install as sourceMapInstall } from 'source-map-support';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import {
AppStartLoggable,
enableOpenApiDocs,
Expand All @@ -24,7 +24,7 @@ async function bootstrap() {
const nestAdminServerApp = await NestFactory.create(AdminApiServerModule, nestAdminServerExpressAdapter);
const logger = await nestAdminServerApp.resolve(Logger);
const legacyLogger = await nestAdminServerApp.resolve(LegacyLogger);
nestAdminServerApp.use(createAppLoggerMiddleware(await nestAdminServerApp.resolve(Logger)));
nestAdminServerApp.use(createRequestLoggerMiddleware(await nestAdminServerApp.resolve(Logger)));

nestAdminServerApp.useLogger(legacyLogger);
nestAdminServerApp.enableCors();
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/apps/board-collaboration.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { RedisIoAdapter } from '@infra/socketio';
import { BoardCollaborationModule } from '@modules/board/board-collaboration.app.module';
import express from 'express';
import { ExpressAdapter } from '@nestjs/platform-express';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import {
enableOpenApiDocs,
addPrometheusMetricsMiddlewaresIfEnabled,
Expand All @@ -38,7 +38,7 @@ async function bootstrap() {
};
enableOpenApiDocs(nestApp, 'docs', options);
const logger = await nestApp.resolve(Logger);
nestApp.use(createAppLoggerMiddleware(await nestApp.resolve(Logger)));
nestApp.use(createRequestLoggerMiddleware(await nestApp.resolve(Logger)));

await nestApp.init();

Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/apps/common-cartridge.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LegacyLogger, Logger } from '@src/core/logger';
import { CommonCartridgeApiModule } from '@modules/common-cartridge/common-cartridge-api.module';
import express from 'express';
import { install as sourceMapInstall } from 'source-map-support';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import {
AppStartLoggable,
enableOpenApiDocs,
Expand All @@ -28,7 +28,7 @@ async function bootstrap() {

const rootExpress = express();
const logger = await nestApp.resolve(Logger);
nestApp.use(createAppLoggerMiddleware(await nestApp.resolve(Logger)));
nestApp.use(createRequestLoggerMiddleware(await nestApp.resolve(Logger)));

addPrometheusMetricsMiddlewaresIfEnabled(logger, rootExpress);

Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/apps/files-storage.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FilesStorageApiModule } from '@modules/files-storage/files-storage-api.
import { API_VERSION_PATH } from '@modules/files-storage/files-storage.const';
import { SwaggerDocumentOptions } from '@nestjs/swagger';
import { LegacyLogger, Logger } from '@src/core/logger';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import { enableOpenApiDocs } from './helpers';

async function bootstrap() {

Check warning on line 18 in apps/server/src/apps/files-storage.app.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Missing return type on function
Expand All @@ -29,7 +29,7 @@ async function bootstrap() {

// customize nest app settings
nestApp.enableCors({ exposedHeaders: ['Content-Disposition'] });
nestApp.use(createAppLoggerMiddleware(await nestApp.resolve(Logger)));
nestApp.use(createRequestLoggerMiddleware(await nestApp.resolve(Logger)));

const options: SwaggerDocumentOptions = {
operationIdFactory: (_controllerKey: string, methodKey: string) => methodKey,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/apps/fwu-learning-contents.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { install as sourceMapInstall } from 'source-map-support';
// application imports
import { LegacyLogger, Logger } from '@src/core/logger';
import { FwuLearningContentsModule } from '@modules/fwu-learning-contents';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import { enableOpenApiDocs } from './helpers';

async function bootstrap() {

Check warning on line 16 in apps/server/src/apps/fwu-learning-contents.app.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Missing return type on function
Expand All @@ -27,7 +27,7 @@ async function bootstrap() {
// customize nest app settings
nestApp.enableCors({ exposedHeaders: ['Content-Disposition'] });
enableOpenApiDocs(nestApp, 'docs');
nestApp.use(createAppLoggerMiddleware(await nestApp.resolve(Logger)));
nestApp.use(createRequestLoggerMiddleware(await nestApp.resolve(Logger)));

await nestApp.init();

Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/apps/h5p-editor.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { install as sourceMapInstall } from 'source-map-support';
// application imports
import { LegacyLogger, Logger } from '@src/core/logger';
import { H5PEditorModule } from '@modules/h5p-editor';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import { enableOpenApiDocs } from './helpers';

async function bootstrap() {

Check warning on line 16 in apps/server/src/apps/h5p-editor.app.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Missing return type on function
Expand All @@ -25,7 +25,7 @@ async function bootstrap() {
// WinstonLogger
nestApp.useLogger(await nestApp.resolve(LegacyLogger));

nestApp.use(createAppLoggerMiddleware(await nestApp.resolve(Logger)));
nestApp.use(createRequestLoggerMiddleware(await nestApp.resolve(Logger)));

// customize nest app settings
nestApp.enableCors({ exposedHeaders: ['Content-Disposition'] });
Expand Down
22 changes: 0 additions & 22 deletions apps/server/src/apps/helpers/logger-middleware.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Logger } from '@src/core/logger';
import { RequestLoggable } from '@src/apps/helpers/request-loggable';
import { Configuration } from '@hpi-schul-cloud/commons/lib';

export const createAppLoggerMiddleware = (
export const createRequestLoggerMiddleware = (
logger: Logger
): ((request: Request, response: Response, next: NextFunction) => void) => {
logger.setContext('AppLoggerMiddleware');
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/apps/management.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { install as sourceMapInstall } from 'source-map-support';
// application imports
import { LegacyLogger, Logger } from '@src/core/logger';
import { ManagementServerModule } from '@modules/management';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import { enableOpenApiDocs } from './helpers';

async function bootstrap() {
Expand All @@ -22,7 +22,7 @@ async function bootstrap() {
const nestExpressAdapter = new ExpressAdapter(nestExpress);
const nestApp = await NestFactory.create(ManagementServerModule, nestExpressAdapter);

nestApp.use(createAppLoggerMiddleware(await nestApp.resolve(Logger)));
nestApp.use(createRequestLoggerMiddleware(await nestApp.resolve(Logger)));

// WinstonLogger
nestApp.useLogger(await nestApp.resolve(LegacyLogger));
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/apps/server.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { join } from 'path';

// register source-map-support for debugging
import { install as sourceMapInstall } from 'source-map-support';
import { createAppLoggerMiddleware } from '@src/apps/helpers/app-logger-middleware';
import { createRequestLoggerMiddleware } from './helpers/request-logger-middleware';
import {
AppStartLoggable,
enableOpenApiDocs,
Expand All @@ -46,7 +46,7 @@ async function bootstrap() {
nestApp.useLogger(legacyLogger);

const logger = await nestApp.resolve(Logger);
nestApp.use(createAppLoggerMiddleware(await nestApp.resolve(Logger)));
nestApp.use(createRequestLoggerMiddleware(await nestApp.resolve(Logger)));

// load the legacy feathers/express server
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand Down

0 comments on commit ce87e6d

Please sign in to comment.