diff --git a/federation/jest.config.js b/federation/jest.config.js index dff5ab169..f055d66e2 100644 --- a/federation/jest.config.js +++ b/federation/jest.config.js @@ -3,12 +3,7 @@ module.exports = { verbose: true, preset: 'ts-jest', collectCoverage: true, - collectCoverageFrom: [ - 'src/**/*.ts', - '!**/node_modules/**', - '!src/seeds/**', - '!build/**', - ], + collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'], coverageThreshold: { global: { lines: 72, diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index 66d8a056c..710248472 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -36,21 +36,18 @@ const database = { DB_USER: process.env.DB_USER || 'root', DB_PASSWORD: process.env.DB_PASSWORD || '', DB_DATABASE: process.env.DB_DATABASE || 'gradido_community', - TYPEORM_LOGGING_RELATIVE_PATH: - process.env.TYPEORM_LOGGING_RELATIVE_PATH || 'typeorm.backend.log', + TYPEORM_LOGGING_RELATIVE_PATH: process.env.TYPEORM_LOGGING_RELATIVE_PATH || 'typeorm.backend.log', } // Check config version -constants.CONFIG_VERSION.CURRENT = - process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT +constants.CONFIG_VERSION.CURRENT = process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT if ( - ![ - constants.CONFIG_VERSION.EXPECTED, - constants.CONFIG_VERSION.DEFAULT, - ].includes(constants.CONFIG_VERSION.CURRENT) + ![constants.CONFIG_VERSION.EXPECTED, constants.CONFIG_VERSION.DEFAULT].includes( + constants.CONFIG_VERSION.CURRENT, + ) ) { throw new Error( - `Fatal: Config Version incorrect - expected "${constants.CONFIG_VERSION.EXPECTED}" or "${constants.CONFIG_VERSION.DEFAULT}", but found "${constants.CONFIG_VERSION.CURRENT}"` + `Fatal: Config Version incorrect - expected "${constants.CONFIG_VERSION.EXPECTED}" or "${constants.CONFIG_VERSION.DEFAULT}", but found "${constants.CONFIG_VERSION.CURRENT}"`, ) } diff --git a/federation/src/graphql/api/schema.ts b/federation/src/graphql/api/schema.ts index b520dbc59..6ba0bff56 100644 --- a/federation/src/graphql/api/schema.ts +++ b/federation/src/graphql/api/schema.ts @@ -5,8 +5,5 @@ import { federationLogger as logger } from '@/server/logger' export const getApiResolvers = (): string => { logger.info(`getApiResolvers...${CONFIG.FEDERATION_API}`) - return path.join( - __dirname, - `./${CONFIG.FEDERATION_API}/resolver/*Resolver.{ts,js}` - ) + return path.join(__dirname, `./${CONFIG.FEDERATION_API}/resolver/*Resolver.{ts,js}`) } diff --git a/federation/src/index.ts b/federation/src/index.ts index 71c7545aa..997edb7aa 100644 --- a/federation/src/index.ts +++ b/federation/src/index.ts @@ -14,13 +14,11 @@ async function main() { app.listen(CONFIG.FEDERATION_PORT, () => { // eslint-disable-next-line no-console - console.log( - `Server is running at http://localhost:${CONFIG.FEDERATION_PORT}` - ) + console.log(`Server is running at http://localhost:${CONFIG.FEDERATION_PORT}`) if (CONFIG.GRAPHIQL) { // eslint-disable-next-line no-console console.log( - `GraphIQL available at ${CONFIG.FEDERATION_COMMUNITY_URL}/api/${CONFIG.FEDERATION_API}` + `GraphIQL available at ${CONFIG.FEDERATION_COMMUNITY_URL}/api/${CONFIG.FEDERATION_API}`, ) } }) diff --git a/federation/src/server/createServer.ts b/federation/src/server/createServer.ts index c490fbc32..a47b6da7f 100644 --- a/federation/src/server/createServer.ts +++ b/federation/src/server/createServer.ts @@ -36,7 +36,7 @@ type ServerDef = { apollo: ApolloServer; app: Express; con: Connection } const createServer = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any // context: any = serverContext, - logger: Logger = apolloLogger + logger: Logger = apolloLogger, // localization: i18n.I18n = i18n, ): Promise => { logger.addContext('user', 'unknown') diff --git a/federation/src/server/logger.ts b/federation/src/server/logger.ts index 711d571a3..dd2a50cf3 100644 --- a/federation/src/server/logger.ts +++ b/federation/src/server/logger.ts @@ -12,25 +12,13 @@ options.appenders.federation.filename = filename .replace('%v', CONFIG.FEDERATION_API) .replace('%p', CONFIG.FEDERATION_PORT.toString()) filename = options.appenders.access.filename -options.appenders.access.filename = filename.replace( - '%p', - CONFIG.FEDERATION_PORT.toString() -) +options.appenders.access.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString()) filename = options.appenders.apollo.filename -options.appenders.apollo.filename = filename.replace( - '%p', - CONFIG.FEDERATION_PORT.toString() -) +options.appenders.apollo.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString()) filename = options.appenders.backend.filename -options.appenders.backend.filename = filename.replace( - '%p', - CONFIG.FEDERATION_PORT.toString() -) +options.appenders.backend.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString()) filename = options.appenders.errorFile.filename -options.appenders.errorFile.filename = filename.replace( - '%p', - CONFIG.FEDERATION_PORT.toString() -) +options.appenders.errorFile.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString()) log4js.configure(options) diff --git a/federation/src/server/plugins.ts b/federation/src/server/plugins.ts index 38fdfbe9f..7ecbedf2a 100644 --- a/federation/src/server/plugins.ts +++ b/federation/src/server/plugins.ts @@ -34,17 +34,12 @@ const logPlugin = { const { query, mutation, variables, operationName } = requestContext.request if (operationName !== 'IntrospectionQuery') { logger.info(`Request: -${mutation || query}variables: ${JSON.stringify( - filterVariables(variables), - null, - 2 - )}`) +${mutation || query}variables: ${JSON.stringify(filterVariables(variables), null, 2)}`) } return { willSendResponse(requestContext: any) { if (operationName !== 'IntrospectionQuery') { - if (requestContext.context.user) - logger.info(`User ID: ${requestContext.context.user.id}`) + if (requestContext.context.user) logger.info(`User ID: ${requestContext.context.user.id}`) if (requestContext.response.data) { logger.info('Response Success!') logger.trace(`Response-Data: @@ -61,8 +56,6 @@ ${JSON.stringify(requestContext.response.errors, null, 2)}`) } const plugins = - process.env.NODE_ENV === 'development' - ? [setHeadersPlugin] - : [setHeadersPlugin, logPlugin] + process.env.NODE_ENV === 'development' ? [setHeadersPlugin] : [setHeadersPlugin, logPlugin] export default plugins diff --git a/federation/src/typeorm/DBVersion.ts b/federation/src/typeorm/DBVersion.ts index 11f2fe54a..bdb909c1d 100644 --- a/federation/src/typeorm/DBVersion.ts +++ b/federation/src/typeorm/DBVersion.ts @@ -17,7 +17,7 @@ const checkDBVersion = async (DB_VERSION: string): Promise => { logger.error( `Wrong database version detected - the backend requires '${DB_VERSION}' but found '${ dbVersion || 'None' - }` + }`, ) return false }