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,
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,

View File

@ -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}"`,
)
}

View File

@ -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}`)
}

View File

@ -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}`,
)
}
})

View File

@ -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<ServerDef> => {
logger.addContext('user', 'unknown')

View File

@ -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)

View File

@ -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

View File

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