prettier fixes

This commit is contained in:
Ulf Gebhardt 2023-06-09 14:25:40 +02:00
parent 2c61a09017
commit b01da15a75
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
8 changed files with 19 additions and 51 deletions

View File

@ -3,12 +3,7 @@ module.exports = {
verbose: true, verbose: true,
preset: 'ts-jest', preset: 'ts-jest',
collectCoverage: true, collectCoverage: true,
collectCoverageFrom: [ collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'],
'src/**/*.ts',
'!**/node_modules/**',
'!src/seeds/**',
'!build/**',
],
coverageThreshold: { coverageThreshold: {
global: { global: {
lines: 72, lines: 72,

View File

@ -36,21 +36,18 @@ const database = {
DB_USER: process.env.DB_USER || 'root', DB_USER: process.env.DB_USER || 'root',
DB_PASSWORD: process.env.DB_PASSWORD || '', DB_PASSWORD: process.env.DB_PASSWORD || '',
DB_DATABASE: process.env.DB_DATABASE || 'gradido_community', DB_DATABASE: process.env.DB_DATABASE || 'gradido_community',
TYPEORM_LOGGING_RELATIVE_PATH: TYPEORM_LOGGING_RELATIVE_PATH: process.env.TYPEORM_LOGGING_RELATIVE_PATH || 'typeorm.backend.log',
process.env.TYPEORM_LOGGING_RELATIVE_PATH || 'typeorm.backend.log',
} }
// Check config version // Check config version
constants.CONFIG_VERSION.CURRENT = constants.CONFIG_VERSION.CURRENT = process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT
process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT
if ( if (
![ ![constants.CONFIG_VERSION.EXPECTED, constants.CONFIG_VERSION.DEFAULT].includes(
constants.CONFIG_VERSION.EXPECTED, constants.CONFIG_VERSION.CURRENT,
constants.CONFIG_VERSION.DEFAULT, )
].includes(constants.CONFIG_VERSION.CURRENT)
) { ) {
throw new Error( 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}"`,
) )
} }

View File

@ -5,8 +5,5 @@ import { federationLogger as logger } from '@/server/logger'
export const getApiResolvers = (): string => { export const getApiResolvers = (): string => {
logger.info(`getApiResolvers...${CONFIG.FEDERATION_API}`) logger.info(`getApiResolvers...${CONFIG.FEDERATION_API}`)
return path.join( return path.join(__dirname, `./${CONFIG.FEDERATION_API}/resolver/*Resolver.{ts,js}`)
__dirname,
`./${CONFIG.FEDERATION_API}/resolver/*Resolver.{ts,js}`
)
} }

View File

@ -14,13 +14,11 @@ async function main() {
app.listen(CONFIG.FEDERATION_PORT, () => { app.listen(CONFIG.FEDERATION_PORT, () => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log( console.log(`Server is running at http://localhost:${CONFIG.FEDERATION_PORT}`)
`Server is running at http://localhost:${CONFIG.FEDERATION_PORT}`
)
if (CONFIG.GRAPHIQL) { if (CONFIG.GRAPHIQL) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log( console.log(
`GraphIQL available at ${CONFIG.FEDERATION_COMMUNITY_URL}/api/${CONFIG.FEDERATION_API}` `GraphIQL available at ${CONFIG.FEDERATION_COMMUNITY_URL}/api/${CONFIG.FEDERATION_API}`,
) )
} }
}) })

View File

@ -36,7 +36,7 @@ type ServerDef = { apollo: ApolloServer; app: Express; con: Connection }
const createServer = async ( const createServer = async (
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
// context: any = serverContext, // context: any = serverContext,
logger: Logger = apolloLogger logger: Logger = apolloLogger,
// localization: i18n.I18n = i18n, // localization: i18n.I18n = i18n,
): Promise<ServerDef> => { ): Promise<ServerDef> => {
logger.addContext('user', 'unknown') logger.addContext('user', 'unknown')

View File

@ -12,25 +12,13 @@ options.appenders.federation.filename = filename
.replace('%v', CONFIG.FEDERATION_API) .replace('%v', CONFIG.FEDERATION_API)
.replace('%p', CONFIG.FEDERATION_PORT.toString()) .replace('%p', CONFIG.FEDERATION_PORT.toString())
filename = options.appenders.access.filename filename = options.appenders.access.filename
options.appenders.access.filename = filename.replace( options.appenders.access.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
'%p',
CONFIG.FEDERATION_PORT.toString()
)
filename = options.appenders.apollo.filename filename = options.appenders.apollo.filename
options.appenders.apollo.filename = filename.replace( options.appenders.apollo.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
'%p',
CONFIG.FEDERATION_PORT.toString()
)
filename = options.appenders.backend.filename filename = options.appenders.backend.filename
options.appenders.backend.filename = filename.replace( options.appenders.backend.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
'%p',
CONFIG.FEDERATION_PORT.toString()
)
filename = options.appenders.errorFile.filename filename = options.appenders.errorFile.filename
options.appenders.errorFile.filename = filename.replace( options.appenders.errorFile.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
'%p',
CONFIG.FEDERATION_PORT.toString()
)
log4js.configure(options) log4js.configure(options)

View File

@ -34,17 +34,12 @@ const logPlugin = {
const { query, mutation, variables, operationName } = requestContext.request const { query, mutation, variables, operationName } = requestContext.request
if (operationName !== 'IntrospectionQuery') { if (operationName !== 'IntrospectionQuery') {
logger.info(`Request: logger.info(`Request:
${mutation || query}variables: ${JSON.stringify( ${mutation || query}variables: ${JSON.stringify(filterVariables(variables), null, 2)}`)
filterVariables(variables),
null,
2
)}`)
} }
return { return {
willSendResponse(requestContext: any) { willSendResponse(requestContext: any) {
if (operationName !== 'IntrospectionQuery') { if (operationName !== 'IntrospectionQuery') {
if (requestContext.context.user) if (requestContext.context.user) logger.info(`User ID: ${requestContext.context.user.id}`)
logger.info(`User ID: ${requestContext.context.user.id}`)
if (requestContext.response.data) { if (requestContext.response.data) {
logger.info('Response Success!') logger.info('Response Success!')
logger.trace(`Response-Data: logger.trace(`Response-Data:
@ -61,8 +56,6 @@ ${JSON.stringify(requestContext.response.errors, null, 2)}`)
} }
const plugins = const plugins =
process.env.NODE_ENV === 'development' process.env.NODE_ENV === 'development' ? [setHeadersPlugin] : [setHeadersPlugin, logPlugin]
? [setHeadersPlugin]
: [setHeadersPlugin, logPlugin]
export default plugins export default plugins

View File

@ -17,7 +17,7 @@ const checkDBVersion = async (DB_VERSION: string): Promise<boolean> => {
logger.error( logger.error(
`Wrong database version detected - the backend requires '${DB_VERSION}' but found '${ `Wrong database version detected - the backend requires '${DB_VERSION}' but found '${
dbVersion || 'None' dbVersion || 'None'
}` }`,
) )
return false return false
} }