mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
fix linting
This commit is contained in:
parent
1f4edb45b2
commit
39945345ec
@ -1,5 +1,5 @@
|
||||
import { Migration, entities } from '@/entity'
|
||||
import { DataSource as DBDataSource, FileLogger } from 'typeorm'
|
||||
import { entities, Migration } from '@/entity'
|
||||
|
||||
import { CONFIG } from '@/config'
|
||||
import { logger } from '@/logging'
|
||||
@ -37,8 +37,10 @@ export class AppDatabase {
|
||||
|
||||
// create database connection, initialize with automatic retry and check for correct database version
|
||||
public async init(): Promise<void> {
|
||||
if (this.connection?.isInitialized) return
|
||||
|
||||
if (this.connection?.isInitialized) {
|
||||
return
|
||||
}
|
||||
|
||||
// log sql query only of enable by .env, this produce so much data it should be only used when really needed
|
||||
const logging: boolean = CONFIG.TYPEORM_LOGGING_ACTIVE
|
||||
this.connection = new DBDataSource({
|
||||
@ -52,9 +54,11 @@ export class AppDatabase {
|
||||
entities,
|
||||
synchronize: false,
|
||||
logging,
|
||||
logger: logging ? new FileLogger('all', {
|
||||
logPath: CONFIG.TYPEORM_LOGGING_RELATIVE_PATH,
|
||||
}) : undefined,
|
||||
logger: logging
|
||||
? new FileLogger('all', {
|
||||
logPath: CONFIG.TYPEORM_LOGGING_RELATIVE_PATH,
|
||||
})
|
||||
: undefined,
|
||||
extra: {
|
||||
charset: 'utf8mb4_unicode_ci',
|
||||
},
|
||||
@ -63,7 +67,7 @@ export class AppDatabase {
|
||||
for (let attempt = 1; attempt <= CONFIG.DB_CONNECT_RETRY_COUNT; attempt++) {
|
||||
try {
|
||||
await this.connection.initialize()
|
||||
if(this.connection.isInitialized) {
|
||||
if (this.connection.isInitialized) {
|
||||
logger.info(`Database connection established on attempt ${attempt}`)
|
||||
break
|
||||
}
|
||||
@ -87,7 +91,7 @@ export class AppDatabase {
|
||||
// ######################################
|
||||
private async checkDBVersion(): Promise<void> {
|
||||
const [dbVersion] = await Migration.find({ order: { version: 'DESC' }, take: 1 })
|
||||
if(!dbVersion) {
|
||||
if (!dbVersion) {
|
||||
throw new Error('Could not find database version')
|
||||
}
|
||||
if (!dbVersion.fileName.startsWith(latestDbVersion)) {
|
||||
@ -96,7 +100,7 @@ export class AppDatabase {
|
||||
dbVersion.fileName
|
||||
}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ const constants = {
|
||||
EXPECTED: 'v1.2022-03-18',
|
||||
CURRENT: '',
|
||||
},
|
||||
LOG4JS_CATEGORY_NAME: 'database'
|
||||
LOG4JS_CATEGORY_NAME: 'database',
|
||||
}
|
||||
|
||||
const database = {
|
||||
@ -23,7 +23,8 @@ 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.database.log',
|
||||
TYPEORM_LOGGING_RELATIVE_PATH:
|
||||
process.env.TYPEORM_LOGGING_RELATIVE_PATH ?? 'typeorm.database.log',
|
||||
TYPEORM_LOGGING_ACTIVE: process.env.TYPEORM_LOGGING_ACTIVE === 'true' || false,
|
||||
}
|
||||
|
||||
|
||||
@ -9,9 +9,9 @@ import {
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { GeometryTransformer } from './transformer/GeometryTransformer'
|
||||
import { FederatedCommunity } from './FederatedCommunity'
|
||||
import { User } from './User'
|
||||
import { GeometryTransformer } from './transformer/GeometryTransformer'
|
||||
|
||||
@Entity('communities')
|
||||
export class Community extends BaseEntity {
|
||||
|
||||
@ -10,10 +10,10 @@ import {
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm'
|
||||
import { DecimalTransformer } from './transformer/DecimalTransformer'
|
||||
import { ContributionMessage } from './ContributionMessage'
|
||||
import { Transaction } from './Transaction'
|
||||
import { User } from './User'
|
||||
import { DecimalTransformer } from './transformer/DecimalTransformer'
|
||||
|
||||
@Entity('contributions')
|
||||
export class Contribution extends BaseEntity {
|
||||
|
||||
@ -8,13 +8,13 @@ import {
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm'
|
||||
import { DecimalTransformer } from './transformer/DecimalTransformer'
|
||||
import { Contribution } from './Contribution'
|
||||
import { ContributionLink } from './ContributionLink'
|
||||
import { ContributionMessage } from './ContributionMessage'
|
||||
import { Transaction } from './Transaction'
|
||||
import { TransactionLink } from './TransactionLink'
|
||||
import { User } from './User'
|
||||
import { DecimalTransformer } from './transformer/DecimalTransformer'
|
||||
|
||||
@Entity('events')
|
||||
export class Event extends BaseEntity {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
/* eslint-disable no-use-before-define */
|
||||
import { Decimal } from 'decimal.js-light'
|
||||
import { BaseEntity, Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm'
|
||||
import { DecimalTransformer } from './transformer/DecimalTransformer'
|
||||
import { Contribution } from './Contribution'
|
||||
import { DltTransaction } from './DltTransaction'
|
||||
import { DecimalTransformer } from './transformer/DecimalTransformer'
|
||||
|
||||
@Entity('transactions')
|
||||
export class Transaction extends BaseEntity {
|
||||
|
||||
@ -10,12 +10,12 @@ import {
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm'
|
||||
import { GeometryTransformer } from './transformer/GeometryTransformer'
|
||||
import { Community } from './Community'
|
||||
import { Contribution } from './Contribution'
|
||||
import { ContributionMessage } from './ContributionMessage'
|
||||
import { UserContact } from './UserContact'
|
||||
import { UserRole } from './UserRole'
|
||||
import { GeometryTransformer } from './transformer/GeometryTransformer'
|
||||
|
||||
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||
export class User extends BaseEntity {
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { CONFIG } from '@/config'
|
||||
import { getLogger } from 'log4js'
|
||||
import { AbstractLoggingView } from './AbstractLogging.view'
|
||||
import { CommunityLoggingView } from './CommunityLogging.view'
|
||||
import { ContributionLoggingView } from './ContributionLogging.view'
|
||||
@ -9,8 +11,6 @@ import { TransactionLoggingView } from './TransactionLogging.view'
|
||||
import { UserContactLoggingView } from './UserContactLogging.view'
|
||||
import { UserLoggingView } from './UserLogging.view'
|
||||
import { UserRoleLoggingView } from './UserRoleLogging.view'
|
||||
import { CONFIG } from '@/config'
|
||||
import { getLogger } from 'log4js'
|
||||
|
||||
export {
|
||||
AbstractLoggingView,
|
||||
@ -26,4 +26,4 @@ export {
|
||||
UserRoleLoggingView,
|
||||
}
|
||||
|
||||
export const logger = getLogger(CONFIG.LOG4JS_CATEGORY_NAME)
|
||||
export const logger = getLogger(CONFIG.LOG4JS_CATEGORY_NAME)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user