diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 79276ef9d..59bd53ca6 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -76,7 +76,21 @@ module.exports = { 'import/no-named-default': 'error', 'import/no-namespace': 'error', 'import/no-unassigned-import': 'error', - 'import/order': 'error', + 'import/order': [ + 'error', + { + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'], + 'newlines-between': 'always', + pathGroups: [ + { + pattern: '@*/**', + group: 'external', + position: 'after', + }, + ], + distinctGroup: false, + }, + ], 'import/prefer-default-export': 'off', // TODO }, overrides: [ diff --git a/backend/src/apis/HttpRequest.ts b/backend/src/apis/HttpRequest.ts index eff0c408a..af7e40dd7 100644 --- a/backend/src/apis/HttpRequest.ts +++ b/backend/src/apis/HttpRequest.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import axios from 'axios' - import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index 70c0f95b1..309cf56ee 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -4,9 +4,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import CONFIG from '@/config' + // eslint-disable-next-line import/no-relative-parent-imports import KlicktippConnector from 'klicktipp-api' -import CONFIG from '@/config' const klicktippConnector = new KlicktippConnector() diff --git a/backend/src/auth/JWT.ts b/backend/src/auth/JWT.ts index 3da1f1d3e..f0a320efb 100644 --- a/backend/src/auth/JWT.ts +++ b/backend/src/auth/JWT.ts @@ -1,8 +1,9 @@ import { verify, sign } from 'jsonwebtoken' -import { CustomJwtPayload } from './CustomJwtPayload' import CONFIG from '@/config/' import LogError from '@/server/LogError' +import { CustomJwtPayload } from './CustomJwtPayload' + export const decode = (token: string): CustomJwtPayload | null => { if (!token) throw new LogError('401 Unauthorized') try { diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index 762b88cf0..5eea352fb 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -1,10 +1,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ import { createTransport } from 'nodemailer' -import { sendEmailTranslated } from './sendEmailTranslated' import { logger, i18n } from '@test/testSetup' import CONFIG from '@/config' +import { sendEmailTranslated } from './sendEmailTranslated' + CONFIG.EMAIL = false CONFIG.EMAIL_SMTP_URL = 'EMAIL_SMTP_URL' CONFIG.EMAIL_SMTP_PORT = '1234' diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index d865bac8f..5cc136edc 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import path from 'path' + import { createTransport } from 'nodemailer' import Email from 'email-templates' import i18n from 'i18n' diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 399ed89ac..76d8f9a26 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -4,6 +4,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Decimal } from 'decimal.js-light' +import { testEnvironment } from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' +import CONFIG from '@/config' + +import { sendEmailTranslated } from './sendEmailTranslated' import { sendAddedContributionMessageEmail, sendAccountActivationEmail, @@ -15,10 +20,6 @@ import { sendTransactionLinkRedeemedEmail, sendTransactionReceivedEmail, } from './sendEmailVariants' -import { sendEmailTranslated } from './sendEmailTranslated' -import { testEnvironment } from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' -import CONFIG from '@/config' let con: any let testEnv: any diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index 2294ebdd5..7da0424dc 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -1,8 +1,9 @@ import { Decimal } from 'decimal.js-light' -import { sendEmailTranslated } from './sendEmailTranslated' import CONFIG from '@/config' import { decimalSeparatorByLanguage } from '@/util/utilities' +import { sendEmailTranslated } from './sendEmailTranslated' + export const sendAddedContributionMessageEmail = (data: { firstName: string lastName: string diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts index 33c9ae36e..e53a56c11 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts index bf85345cf..530c896ca 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts index dd37c76b5..1d776a9e0 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts index 8d34be87f..98d42fcdc 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts index b7ee39c36..3cd55a40c 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts index b5816e45d..d6eb5f205 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts @@ -1,6 +1,7 @@ import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts index 1cd998e26..deb7bb574 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts index f07d38e98..68a59da27 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,6 +2,7 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts index 7d1bc175e..06a5da0c0 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_USER_DELETE.ts b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts index bfd5be740..6c022ad2c 100644 --- a/backend/src/event/EVENT_ADMIN_USER_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_USER_DELETE = async (user: DbUser, moderator: DbUser): Promise => diff --git a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts index 3be825ad4..e6951d062 100644 --- a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts +++ b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_USER_ROLE_SET = async ( diff --git a/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts index eb861dbf1..303c4d260 100644 --- a/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts +++ b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_USER_UNDELETE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts index f1469c725..b01bad47a 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts index 8c62e3ae6..fdfc12448 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts index 9f44de95d..3ce38cf03 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts @@ -4,6 +4,7 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts index b06685a6d..b977f90da 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,6 +2,7 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts index c2e6951cc..be1d3d4ed 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts index c16bbfac3..0133ab715 100644 --- a/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts +++ b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts index ae10f9fba..6132484da 100644 --- a/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts +++ b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_ADMIN_CONFIRMATION = async ( diff --git a/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts index 9d64207e0..44eb9323d 100644 --- a/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts +++ b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_CONFIRMATION = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts index f7e328369..20eb5f1fe 100644 --- a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts +++ b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_FORGOT_PASSWORD = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts index e766fe38e..dd97a0641 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts index d15c786a8..de4511b9e 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts @@ -1,6 +1,7 @@ import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts index 5f8cd5c4d..d699f3d41 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts index c6e06ccb7..d82bbd31c 100644 --- a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts +++ b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_RECEIVE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_SEND.ts b/backend/src/event/EVENT_TRANSACTION_SEND.ts index 888162747..d2fd615a5 100644 --- a/backend/src/event/EVENT_TRANSACTION_SEND.ts +++ b/backend/src/event/EVENT_TRANSACTION_SEND.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_SEND = async ( diff --git a/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts index 2e224d550..602acb880 100644 --- a/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts +++ b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_INFO_UPDATE.ts b/backend/src/event/EVENT_USER_INFO_UPDATE.ts index 681ecd473..080c68e2c 100644 --- a/backend/src/event/EVENT_USER_INFO_UPDATE.ts +++ b/backend/src/event/EVENT_USER_INFO_UPDATE.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_INFO_UPDATE = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_LOGIN.ts b/backend/src/event/EVENT_USER_LOGIN.ts index 351ec5a95..ba09bc02c 100644 --- a/backend/src/event/EVENT_USER_LOGIN.ts +++ b/backend/src/event/EVENT_USER_LOGIN.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_LOGIN = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_LOGOUT.ts b/backend/src/event/EVENT_USER_LOGOUT.ts index 4f5650fc6..2e6c54841 100644 --- a/backend/src/event/EVENT_USER_LOGOUT.ts +++ b/backend/src/event/EVENT_USER_LOGOUT.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_LOGOUT = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_REGISTER.ts b/backend/src/event/EVENT_USER_REGISTER.ts index cdb8b22e2..990ac396f 100644 --- a/backend/src/event/EVENT_USER_REGISTER.ts +++ b/backend/src/event/EVENT_USER_REGISTER.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_REGISTER = async (user: DbUser): Promise => diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index feb167adf..1ff8ba995 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -6,6 +6,7 @@ import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Decimal } from 'decimal.js-light' + import { EventType } from './EventType' export const Event = ( diff --git a/backend/src/federation/validateCommunities.test.ts b/backend/src/federation/validateCommunities.test.ts index a99bb3274..919a99547 100644 --- a/backend/src/federation/validateCommunities.test.ts +++ b/backend/src/federation/validateCommunities.test.ts @@ -6,10 +6,11 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Community as DbCommunity } from '@entity/Community' -import { validateCommunities } from './validateCommunities' import { logger } from '@test/testSetup' import { testEnvironment, cleanDB } from '@test/helpers' +import { validateCommunities } from './validateCommunities' + let con: any let testEnv: any diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index 19185e4d9..c4a9f3b1d 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -1,12 +1,13 @@ import { Community as DbCommunity } from '@entity/Community' import { IsNull } from '@dbTools/typeorm' +import { backendLogger as logger } from '@/server/logger' +import LogError from '@/server/LogError' + // eslint-disable-next-line camelcase import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient' // eslint-disable-next-line camelcase import { requestGetPublicKey as v1_1_requestGetPublicKey } from './client/1_1/FederationClient' import { ApiVersionType } from './enum/apiVersionType' -import { backendLogger as logger } from '@/server/logger' -import LogError from '@/server/LogError' export function startValidateCommunities(timerInterval: number): void { logger.info( diff --git a/backend/src/graphql/directive/isAuthorized.ts b/backend/src/graphql/directive/isAuthorized.ts index 6cdac9b97..845593de6 100644 --- a/backend/src/graphql/directive/isAuthorized.ts +++ b/backend/src/graphql/directive/isAuthorized.ts @@ -3,7 +3,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { AuthChecker } from 'type-graphql' - import { User } from '@entity/User' import { decode, encode } from '@/auth/JWT' import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES' diff --git a/backend/src/graphql/model/GdtEntryList.ts b/backend/src/graphql/model/GdtEntryList.ts index d992de54c..06f77f532 100644 --- a/backend/src/graphql/model/GdtEntryList.ts +++ b/backend/src/graphql/model/GdtEntryList.ts @@ -4,6 +4,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { ObjectType, Field, Int, Float } from 'type-graphql' + import { GdtEntry } from './GdtEntry' @ObjectType() diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index 8f0d1eadc..0a31cd8d6 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -1,9 +1,10 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' +import { TransactionTypeId } from '@enum/TransactionTypeId' + import { Decay } from './Decay' import { User } from './User' -import { TransactionTypeId } from '@enum/TransactionTypeId' @ObjectType() export class Transaction { diff --git a/backend/src/graphql/model/TransactionLink.ts b/backend/src/graphql/model/TransactionLink.ts index ddd22f36f..1ed02b476 100644 --- a/backend/src/graphql/model/TransactionLink.ts +++ b/backend/src/graphql/model/TransactionLink.ts @@ -1,9 +1,10 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { User } from './User' import CONFIG from '@/config' +import { User } from './User' + @ObjectType() export class TransactionLink { constructor(transactionLink: dbTransactionLink, user: User, redeemedBy: User | null = null) { diff --git a/backend/src/graphql/model/TransactionList.ts b/backend/src/graphql/model/TransactionList.ts index 888c30dc7..36e51242d 100644 --- a/backend/src/graphql/model/TransactionList.ts +++ b/backend/src/graphql/model/TransactionList.ts @@ -1,4 +1,5 @@ import { ObjectType, Field } from 'type-graphql' + import { Transaction } from './Transaction' import { Balance } from './Balance' diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 85c6de798..6797b0767 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,5 +1,6 @@ import { ObjectType, Field, Int } from 'type-graphql' import { User as dbUser } from '@entity/User' + import { KlickTipp } from './KlickTipp' import { UserContact } from './UserContact' diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index 7600f12b9..0a9b651a9 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -2,21 +2,18 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Query, Ctx, Authorized } from 'type-graphql' import { getCustomRepository } from '@dbTools/typeorm' - import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' - -import { GdtResolver } from './GdtResolver' -import { getLastTransaction } from './util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' - import { Balance } from '@model/Balance' - import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' import { calculateDecay } from '@/util/decay' import { RIGHTS } from '@/auth/RIGHTS' +import { getLastTransaction } from './util/getLastTransaction' +import { GdtResolver } from './GdtResolver' + @Resolver() export class BalanceResolver { @Authorized([RIGHTS.BALANCE]) diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 6aca41472..37c42dd89 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -1,8 +1,6 @@ import { Resolver, Query, Authorized } from 'type-graphql' - import { Community as DbCommunity } from '@entity/Community' import { Community } from '@model/Community' - import { RIGHTS } from '@/auth/RIGHTS' @Resolver() diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index 55a23187f..5febb95c5 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -1,23 +1,13 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql' import { MoreThan, IsNull } from '@dbTools/typeorm' - import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { - CONTRIBUTIONLINK_NAME_MAX_CHARS, - CONTRIBUTIONLINK_NAME_MIN_CHARS, - MEMO_MAX_CHARS, - MEMO_MIN_CHARS, -} from './const/const' -import { isStartEndDateValid } from './util/creations' -import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import { ContributionLinkList } from '@model/ContributionLinkList' import { ContributionLink } from '@model/ContributionLink' import ContributionLinkArgs from '@arg/ContributionLinkArgs' import { RIGHTS } from '@/auth/RIGHTS' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' - // TODO: this is a strange construct import LogError from '@/server/LogError' import { Context, getUser } from '@/server/context' @@ -27,6 +17,15 @@ import { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE, } from '@/event/Event' +import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' +import { isStartEndDateValid } from './util/creations' +import { + CONTRIBUTIONLINK_NAME_MAX_CHARS, + CONTRIBUTIONLINK_NAME_MIN_CHARS, + MEMO_MAX_CHARS, + MEMO_MIN_CHARS, +} from './const/const' + @Resolver() export class ContributionLinkResolver { @Authorized([RIGHTS.CREATE_CONTRIBUTION_LINK]) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index 999ccc2b1..63cf2fd9c 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -1,19 +1,16 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' - import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Contribution as DbContribution } from '@entity/Contribution' import { UserContact as DbUserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' - import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' import ContributionMessageArgs from '@arg/ContributionMessageArgs' import { ContributionMessageType } from '@enum/MessageType' import { ContributionStatus } from '@enum/ContributionStatus' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' - import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 83cf29fc7..026793b5f 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -2,23 +2,11 @@ import { Decimal } from 'decimal.js-light' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { IsNull, getConnection } from '@dbTools/typeorm' - import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage } from '@entity/ContributionMessage' import { UserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' - -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' -import { getLastTransaction } from './util/getLastTransaction' -import { findContributions } from './util/findContributions' -import { - getUserCreation, - validateContribution, - updateCreations, - isValidDateString, - getOpenCreations, -} from './util/creations' import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { Contribution, ContributionListResult } from '@model/Contribution' import { Decay } from '@model/Decay' @@ -33,7 +21,6 @@ import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs' import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' - import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import { backendLogger as logger } from '@/server/logger' @@ -56,6 +43,17 @@ import { import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' +import { + getUserCreation, + validateContribution, + updateCreations, + isValidDateString, + getOpenCreations, +} from './util/creations' +import { findContributions } from './util/findContributions' +import { getLastTransaction } from './util/getLastTransaction' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' + @Resolver() export class ContributionResolver { @Authorized([RIGHTS.CREATE_CONTRIBUTION]) diff --git a/backend/src/graphql/resolver/GdtResolver.ts b/backend/src/graphql/resolver/GdtResolver.ts index e12f92458..e5ad56f2d 100644 --- a/backend/src/graphql/resolver/GdtResolver.ts +++ b/backend/src/graphql/resolver/GdtResolver.ts @@ -2,11 +2,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-graphql' - import { GdtEntryList } from '@model/GdtEntryList' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' - import { Context, getUser } from '@/server/context' import CONFIG from '@/config' import { apiGet, apiPost } from '@/apis/HttpRequest' diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index 31bde0581..f8aee5e2c 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Authorized, Arg, Mutation, Ctx } from 'type-graphql' - import { getKlickTippUser, getKlicktippTagMap, diff --git a/backend/src/graphql/resolver/StatisticsResolver.ts b/backend/src/graphql/resolver/StatisticsResolver.ts index d5ae9503c..f16a2fd56 100644 --- a/backend/src/graphql/resolver/StatisticsResolver.ts +++ b/backend/src/graphql/resolver/StatisticsResolver.ts @@ -3,12 +3,9 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' - import { Transaction as DbTransaction } from '@entity/Transaction' import { User as DbUser } from '@entity/User' - import { CommunityStatistics, DynamicStatisticsFields } from '@model/CommunityStatistics' - import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index fd2a44b4b..0ac73cbcf 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -13,7 +13,6 @@ import { GraphQLError } from 'graphql' import { Transaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' import { UserContact } from '@entity/UserContact' -import { transactionLinkCode } from './TransactionLinkResolver' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' @@ -38,6 +37,8 @@ import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { logger } from '@test/testSetup' import { EventType } from '@/event/Event' +import { transactionLinkCode } from './TransactionLinkResolver' + // mock semaphore to allow use fake timers jest.mock('@/util/TRANSACTIONS_LOCK') TRANSACTIONS_LOCK.acquire = jest.fn().mockResolvedValue(jest.fn()) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 6aa829ac1..e9a388cde 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -1,19 +1,13 @@ import { randomBytes } from 'crypto' + import { Decimal } from 'decimal.js-light' - import { getConnection } from '@dbTools/typeorm' - import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' - import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' -import { getUserCreation, validateContribution } from './util/creations' -import { executeTransaction } from './TransactionResolver' -import { getLastTransaction } from './util/getLastTransaction' -import transactionLinkList from './util/transactionLinkList' import { User } from '@model/User' import { ContributionLink } from '@model/ContributionLink' import { Decay } from '@model/Decay' @@ -40,6 +34,11 @@ import { EVENT_TRANSACTION_LINK_REDEEM, } from '@/event/Event' +import transactionLinkList from './util/transactionLinkList' +import { getLastTransaction } from './util/getLastTransaction' +import { executeTransaction } from './TransactionResolver' +import { getUserCreation, validateContribution } from './util/creations' + // TODO: do not export, test it inside the resolver export const transactionLinkCode = (date: Date): string => { const time = date.getTime().toString(16) diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index f26234363..baa50e171 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -10,7 +10,6 @@ import { Transaction } from '@entity/Transaction' import { User } from '@entity/User' import { GraphQLError } from 'graphql' import { Event as DbEvent } from '@entity/Event' -import { findUserByEmail } from './UserResolver' import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { @@ -26,6 +25,8 @@ import { stephenHawking } from '@/seeds/users/stephen-hawking' import { cleanDB, testEnvironment } from '@test/helpers' import { logger } from '@test/testSetup' +import { findUserByEmail } from './UserResolver' + let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index f38a4a07b..7f3f1c5f1 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -5,17 +5,11 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' - import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { BalanceResolver } from './BalanceResolver' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' -import { findUserByEmail } from './UserResolver' -import { getLastTransaction } from './util/getLastTransaction' import { TransactionRepository } from '@repository/Transaction' import { TransactionLinkRepository } from '@repository/TransactionLink' - import { User } from '@model/User' import { Transaction } from '@model/Transaction' import { TransactionList } from '@model/TransactionList' @@ -24,7 +18,6 @@ import { TransactionTypeId } from '@enum/TransactionTypeId' import { calculateBalance } from '@/util/validate' import TransactionSendArgs from '@arg/TransactionSendArgs' import Paginated from '@arg/Paginated' - import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' import { RIGHTS } from '@/auth/RIGHTS' @@ -35,10 +28,14 @@ import { sendTransactionReceivedEmail, } from '@/emails/sendEmailVariants' import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Event' - import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' +import { getLastTransaction } from './util/getLastTransaction' +import { findUserByEmail } from './UserResolver' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { BalanceResolver } from './BalanceResolver' + export const executeTransaction = async ( amount: Decimal, memo: string, diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 54d4f583f..5f66e7725 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -16,36 +16,29 @@ import { Int, } from 'type-graphql' import { getConnection, getCustomRepository, IsNull, Not } from '@dbTools/typeorm' - import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { getUserCreations } from './util/creations' -import { FULL_CREATION_AVAILABLE } from './const/const' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { UserRepository } from '@repository/User' - import { User } from '@model/User' import { SearchAdminUsersResult } from '@model/AdminUser' import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' import { OptInType } from '@enum/OptInType' import { Order } from '@enum/Order' import { UserContactType } from '@enum/UserContactType' - import { sendAccountActivationEmail, sendAccountMultiRegistrationEmail, sendResetPasswordEmail, } from '@/emails/sendEmailVariants' - import { getTimeDurationObject, printTimeDuration } from '@/util/time' import CreateUserArgs from '@arg/CreateUserArgs' import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' import Paginated from '@arg/Paginated' import SearchUsersArgs from '@arg/SearchUsersArgs' - import { backendLogger as logger } from '@/server/logger' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import CONFIG from '@/config' @@ -75,6 +68,9 @@ import { isValidPassword } from '@/password/EncryptorUtils' import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor' import LogError from '@/server/LogError' +import { FULL_CREATION_AVAILABLE } from './const/const' +import { getUserCreations } from './util/creations' + // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs diff --git a/backend/src/graphql/resolver/util/creations.test.ts b/backend/src/graphql/resolver/util/creations.test.ts index 7461401c8..a35b37891 100644 --- a/backend/src/graphql/resolver/util/creations.test.ts +++ b/backend/src/graphql/resolver/util/creations.test.ts @@ -6,13 +6,14 @@ import { User } from '@entity/User' import { Contribution } from '@entity/Contribution' -import { getUserCreation } from './creations' import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { userFactory } from '@/seeds/factory/user' import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations' +import { getUserCreation } from './creations' + let mutate: any, con: any let testEnv: any diff --git a/backend/src/graphql/schema.ts b/backend/src/graphql/schema.ts index 194a24c00..1aae117d0 100644 --- a/backend/src/graphql/schema.ts +++ b/backend/src/graphql/schema.ts @@ -1,8 +1,9 @@ import path from 'path' + import { GraphQLSchema } from 'graphql' import { buildSchema } from 'type-graphql' - import { Decimal } from 'decimal.js-light' + import isAuthorized from './directive/isAuthorized' import DecimalScalar from './scalar/Decimal' diff --git a/backend/src/index.ts b/backend/src/index.ts index cd6d002cc..d3ebc42cf 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import createServer from './server/createServer' - // config import CONFIG from './config' import { startValidateCommunities } from './federation/validateCommunities' diff --git a/backend/src/password/PasswordEncryptor.ts b/backend/src/password/PasswordEncryptor.ts index 1735106c1..1c7457a40 100644 --- a/backend/src/password/PasswordEncryptor.ts +++ b/backend/src/password/PasswordEncryptor.ts @@ -1,4 +1,5 @@ import { User } from '@entity/User' + // import { logger } from '@test/testSetup' getting error "jest is not defined" import { getUserCryptographicSalt, SecretKeyCryptographyCreateKey } from './EncryptorUtils' diff --git a/backend/src/seeds/creation/index.ts b/backend/src/seeds/creation/index.ts index 757407438..3f2a545a4 100644 --- a/backend/src/seeds/creation/index.ts +++ b/backend/src/seeds/creation/index.ts @@ -1,6 +1,7 @@ -import { CreationInterface } from './CreationInterface' import { nMonthsBefore } from '@/seeds/factory/creation' +import { CreationInterface } from './CreationInterface' + const bobsSendings = [ { amount: 10, diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 19f936d16..9f945086c 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -8,6 +8,9 @@ import { createTestClient } from 'apollo-server-testing' import { name, internet, datatype } from 'faker' import { entities } from '@entity/index' +import createServer from '@/server/createServer' +import { backendLogger as logger } from '@/server/logger' +import CONFIG from '@/config' import { users } from './users/index' import { creations } from './creation/index' @@ -17,9 +20,6 @@ import { userFactory } from './factory/user' import { creationFactory } from './factory/creation' import { transactionLinkFactory } from './factory/transactionLink' import { contributionLinkFactory } from './factory/contributionLink' -import createServer from '@/server/createServer' -import { backendLogger as logger } from '@/server/logger' -import CONFIG from '@/config' CONFIG.EMAIL = false diff --git a/backend/src/server/LogError.test.ts b/backend/src/server/LogError.test.ts index 318a477ef..5aa1cae21 100644 --- a/backend/src/server/LogError.test.ts +++ b/backend/src/server/LogError.test.ts @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/unbound-method */ -import LogError from './LogError' import { logger } from '@test/testSetup' +import LogError from './LogError' + describe('LogError', () => { it('logs an Error when created', () => { /* eslint-disable-next-line no-new */ diff --git a/backend/src/server/context.ts b/backend/src/server/context.ts index 570865587..1990100dd 100644 --- a/backend/src/server/context.ts +++ b/backend/src/server/context.ts @@ -2,9 +2,10 @@ import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' import { ExpressContext } from 'apollo-server-express' -import LogError from './LogError' import { Role } from '@/auth/Role' +import LogError from './LogError' + export interface Context { token: string | null setHeaders: { key: string; value: string }[] diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index f23e90b56..23e1ad0d2 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -5,17 +5,18 @@ import { ApolloServer } from 'apollo-server-express' import express, { Express, json, urlencoded } from 'express' import { Connection } from '@dbTools/typeorm' import { Logger } from 'log4js' -import cors from './cors' -import serverContext from './context' -import plugins from './plugins' -import { apolloLogger } from './logger' -import { i18n } from './localization' import connection from '@/typeorm/connection' import { checkDBVersion } from '@/typeorm/DBVersion' import CONFIG from '@/config' import schema from '@/graphql/schema' import { elopageWebhook } from '@/webhook/elopage' +import cors from './cors' +import serverContext from './context' +import plugins from './plugins' +import { apolloLogger } from './logger' +import { i18n } from './localization' + // TODO implement // import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity"; diff --git a/backend/src/server/localization.ts b/backend/src/server/localization.ts index 22616fcf0..59ba4cfce 100644 --- a/backend/src/server/localization.ts +++ b/backend/src/server/localization.ts @@ -1,5 +1,7 @@ import path from 'path' + import i18n from 'i18n' + import { backendLogger } from './logger' i18n.configure({ diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index 0887340d4..35587e9c6 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { readFileSync } from 'fs' + import { configure, getLogger } from 'log4js' import CONFIG from '@/config' diff --git a/backend/src/util/decay.test.ts b/backend/src/util/decay.test.ts index b33d18d42..1d4ebab3b 100644 --- a/backend/src/util/decay.test.ts +++ b/backend/src/util/decay.test.ts @@ -1,4 +1,5 @@ import { Decimal } from 'decimal.js-light' + import { decayFormula, calculateDecay } from './decay' describe('utils/decay', () => { diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index ec28dfa13..02128cb87 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -1,11 +1,12 @@ import { Decimal } from 'decimal.js-light' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { calculateDecay } from './decay' import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { Decay } from '@model/Decay' +import { calculateDecay } from './decay' + function isStringBoolean(value: string): boolean { const lowerValue = value.toLowerCase() if (lowerValue === 'true' || lowerValue === 'false') { diff --git a/backend/src/util/virtualTransactions.ts b/backend/src/util/virtualTransactions.ts index 7810ad871..442c06b21 100644 --- a/backend/src/util/virtualTransactions.ts +++ b/backend/src/util/virtualTransactions.ts @@ -2,11 +2,12 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' -import { calculateDecay } from './decay' import { Transaction } from '@model/Transaction' import { TransactionTypeId } from '@enum/TransactionTypeId' import { User } from '@model/User' +import { calculateDecay } from './decay' + const defaultModelFunctions = { hasId: function (): boolean { throw new Error('Function not implemented.') diff --git a/backend/test/helpers.ts b/backend/test/helpers.ts index ad6d2c4e3..b118f7b9d 100644 --- a/backend/test/helpers.ts +++ b/backend/test/helpers.ts @@ -9,9 +9,10 @@ import { createTestClient } from 'apollo-server-testing' import { initialize } from '@dbTools/helpers' import { entities } from '@entity/index' -import { i18n, logger } from './testSetup' import createServer from '@/server/createServer' +import { i18n, logger } from './testSetup' + export const headerPushMock = jest.fn((t) => { context.token = t.value })