Merge branch 'master' into fix-reset-send-coins

This commit is contained in:
Hannes Heine 2023-04-06 16:02:01 +02:00 committed by GitHub
commit 6db9bbf1b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
105 changed files with 428 additions and 347 deletions

View File

@ -18,7 +18,9 @@ module.exports = {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: true,
typescript: {
project: ['./tsconfig.json', '**/tsconfig.json'],
},
node: true,
},
},
@ -55,7 +57,7 @@ module.exports = {
'import/named': 'error',
'import/namespace': 'error',
'import/no-absolute-path': 'error',
'import/no-cycle': 'off',
'import/no-cycle': 'error',
'import/no-dynamic-require': 'error',
'import/no-internal-modules': 'off',
'import/no-relative-packages': 'error',
@ -71,7 +73,7 @@ module.exports = {
'import/group-exports': 'off',
'import/newline-after-import': 'error',
'import/no-anonymous-default-export': 'error',
'import/no-default-export': 'off',
'import/no-default-export': 'error',
'import/no-duplicates': 'error',
'import/no-named-default': 'error',
'import/no-namespace': 'error',
@ -100,7 +102,7 @@ module.exports = {
distinctGroup: true,
},
],
'import/prefer-default-export': 'off', // TODO
'import/prefer-default-export': 'off',
// n
'n/handle-callback-err': 'error',
'n/no-callback-literal': 'error',
@ -160,8 +162,8 @@ module.exports = {
'import/unambiguous': 'off',
},
parserOptions: {
tsconfigRootDir: './',
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
project: ['./tsconfig.json', '**/tsconfig.json'],
// this is to properly reference the referenced project database without requirement of compiling it
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
},

View File

@ -56,17 +56,17 @@
"@types/node": "^16.10.3",
"@types/nodemailer": "^6.4.4",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"apollo-server-testing": "^2.25.2",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.3.0",
"eslint": "^8.37.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard": "^17.0.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-import-resolver-typescript": "^3.5.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-type-graphql": "^1.0.0",
"faker": "^5.5.3",
@ -74,7 +74,7 @@
"jest": "^27.2.4",
"klicktipp-api": "^1.0.2",
"nodemon": "^2.0.7",
"prettier": "^2.3.1",
"prettier": "^2.8.7",
"ts-jest": "^27.0.5",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.14.0",

View File

@ -3,7 +3,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import axios from 'axios'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
// eslint-disable-next-line @typescript-eslint/no-explicit-any

View File

@ -4,7 +4,8 @@
/* 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'
import { CONFIG } from '@/config'
// eslint-disable-next-line import/no-relative-parent-imports
import KlicktippConnector from 'klicktipp-api'

View File

@ -1,7 +1,7 @@
import { verify, sign } from 'jsonwebtoken'
import CONFIG from '@/config/'
import LogError from '@/server/LogError'
import { CONFIG } from '@/config/'
import { LogError } from '@/server/LogError'
import { CustomJwtPayload } from './CustomJwtPayload'

View File

@ -1,4 +1,4 @@
import CONFIG from './index'
import { CONFIG } from './index'
describe('config/index', () => {
describe('decay start block', () => {

View File

@ -121,7 +121,7 @@ const federation = {
Number(process.env.FEDERATION_VALIDATE_COMMUNITY_TIMER) || 60000,
}
const CONFIG = {
export const CONFIG = {
...constants,
...server,
...database,
@ -132,5 +132,3 @@ const CONFIG = {
...webhook,
...federation,
}
export default CONFIG

View File

@ -4,7 +4,7 @@ import { createTransport } from 'nodemailer'
import { logger, i18n } from '@test/testSetup'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import { sendEmailTranslated } from './sendEmailTranslated'

View File

@ -5,8 +5,8 @@ import Email from 'email-templates'
import i18n from 'i18n'
import { createTransport } from 'nodemailer'
import CONFIG from '@/config'
import LogError from '@/server/LogError'
import { CONFIG } from '@/config'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
export const sendEmailTranslated = async (params: {

View File

@ -8,7 +8,7 @@ import { Decimal } from 'decimal.js-light'
import { testEnvironment } from '@test/helpers'
import { logger, i18n as localization } from '@test/testSetup'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import { sendEmailTranslated } from './sendEmailTranslated'
import {

View File

@ -1,6 +1,6 @@
import { Decimal } from 'decimal.js-light'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import { decimalSeparatorByLanguage } from '@/util/utilities'
import { sendEmailTranslated } from './sendEmailTranslated'

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_CREATE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_DELETE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_DENY = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_LINK_CREATE = async (
moderator: DbUser,

View File

@ -2,7 +2,8 @@ import { ContributionLink as DbContributionLink } from '@entity/ContributionLink
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_LINK_DELETE = async (
moderator: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE = async (
moderator: DbUser,

View File

@ -3,7 +3,8 @@ import { ContributionMessage as DbContributionMessage } from '@entity/Contributi
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async (
user: DbUser,

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_USER_DELETE = async (user: DbUser, moderator: DbUser): Promise<DbEvent> =>
Event(EventType.ADMIN_USER_DELETE, user, moderator).save()

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_USER_ROLE_SET = async (
user: DbUser,

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_ADMIN_USER_UNDELETE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_CONTRIBUTION_CREATE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_CONTRIBUTION_DELETE = async (
user: DbUser,

View File

@ -5,7 +5,8 @@ import { Transaction as DbTransaction } from '@entity/Transaction'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_CONTRIBUTION_LINK_REDEEM = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { ContributionMessage as DbContributionMessage } from '@entity/Contributi
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_CONTRIBUTION_UPDATE = async (
user: DbUser,

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.EMAIL_ACCOUNT_MULTIREGISTRATION, user, { id: 0 } as DbUser).save()

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_EMAIL_ADMIN_CONFIRMATION = async (
user: DbUser,

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_EMAIL_CONFIRMATION = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.EMAIL_CONFIRMATION, user, user).save()

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_EMAIL_FORGOT_PASSWORD = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.EMAIL_FORGOT_PASSWORD, user, { id: 0 } as DbUser).save()

View File

@ -3,7 +3,8 @@ import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_TRANSACTION_LINK_CREATE = async (
user: DbUser,

View File

@ -2,7 +2,8 @@ import { Event as DbEvent } from '@entity/Event'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_TRANSACTION_LINK_DELETE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_TRANSACTION_LINK_REDEEM = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Transaction as DbTransaction } from '@entity/Transaction'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_TRANSACTION_RECEIVE = async (
user: DbUser,

View File

@ -3,7 +3,8 @@ import { Transaction as DbTransaction } from '@entity/Transaction'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_TRANSACTION_SEND = async (
user: DbUser,

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_USER_ACTIVATE_ACCOUNT = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.USER_ACTIVATE_ACCOUNT, user, user).save()

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_USER_INFO_UPDATE = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.USER_INFO_UPDATE, user, user).save()

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_USER_LOGIN = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.USER_LOGIN, user, user).save()

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_USER_LOGOUT = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.USER_LOGOUT, user, user).save()

View File

@ -1,7 +1,8 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
import { Event } from './Event'
import { EventType } from './EventType'
export const EVENT_USER_REGISTER = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.USER_REGISTER, user, user).save()

View File

@ -34,37 +34,3 @@ export const Event = (
event.amount = amount
return event
}
export { EventType }
export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM'
export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE'
export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE'
export { EVENT_ADMIN_CONTRIBUTION_DENY } from './EVENT_ADMIN_CONTRIBUTION_DENY'
export { EVENT_ADMIN_CONTRIBUTION_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_UPDATE'
export { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_CREATE'
export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE'
export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE'
export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE'
export { EVENT_ADMIN_USER_DELETE } from './EVENT_ADMIN_USER_DELETE'
export { EVENT_ADMIN_USER_UNDELETE } from './EVENT_ADMIN_USER_UNDELETE'
export { EVENT_ADMIN_USER_ROLE_SET } from './EVENT_ADMIN_USER_ROLE_SET'
export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE'
export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE'
export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE'
export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE'
export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM'
export { EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION } from './EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION'
export { EVENT_EMAIL_ADMIN_CONFIRMATION } from './EVENT_EMAIL_ADMIN_CONFIRMATION'
export { EVENT_EMAIL_CONFIRMATION } from './EVENT_EMAIL_CONFIRMATION'
export { EVENT_EMAIL_FORGOT_PASSWORD } from './EVENT_EMAIL_FORGOT_PASSWORD'
export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND'
export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE'
export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE'
export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE'
export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM'
export { EVENT_USER_ACTIVATE_ACCOUNT } from './EVENT_USER_ACTIVATE_ACCOUNT'
export { EVENT_USER_INFO_UPDATE } from './EVENT_USER_INFO_UPDATE'
export { EVENT_USER_LOGIN } from './EVENT_USER_LOGIN'
export { EVENT_USER_LOGOUT } from './EVENT_USER_LOGOUT'
export { EVENT_USER_REGISTER } from './EVENT_USER_REGISTER'

View File

@ -0,0 +1,33 @@
export { EventType } from './EventType'
export { Event } from './Event'
export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM'
export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE'
export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE'
export { EVENT_ADMIN_CONTRIBUTION_DENY } from './EVENT_ADMIN_CONTRIBUTION_DENY'
export { EVENT_ADMIN_CONTRIBUTION_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_UPDATE'
export { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_CREATE'
export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE'
export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE'
export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE'
export { EVENT_ADMIN_USER_DELETE } from './EVENT_ADMIN_USER_DELETE'
export { EVENT_ADMIN_USER_UNDELETE } from './EVENT_ADMIN_USER_UNDELETE'
export { EVENT_ADMIN_USER_ROLE_SET } from './EVENT_ADMIN_USER_ROLE_SET'
export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE'
export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE'
export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE'
export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE'
export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM'
export { EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION } from './EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION'
export { EVENT_EMAIL_ADMIN_CONFIRMATION } from './EVENT_EMAIL_ADMIN_CONFIRMATION'
export { EVENT_EMAIL_CONFIRMATION } from './EVENT_EMAIL_CONFIRMATION'
export { EVENT_EMAIL_FORGOT_PASSWORD } from './EVENT_EMAIL_FORGOT_PASSWORD'
export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND'
export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE'
export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE'
export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE'
export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM'
export { EVENT_USER_ACTIVATE_ACCOUNT } from './EVENT_USER_ACTIVATE_ACCOUNT'
export { EVENT_USER_INFO_UPDATE } from './EVENT_USER_INFO_UPDATE'
export { EVENT_USER_LOGIN } from './EVENT_USER_LOGIN'
export { EVENT_USER_LOGOUT } from './EVENT_USER_LOGOUT'
export { EVENT_USER_REGISTER } from './EVENT_USER_REGISTER'

View File

@ -5,7 +5,7 @@ import { Community as DbCommunity } from '@entity/Community'
import { gql } from 'graphql-request'
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {

View File

@ -5,7 +5,7 @@ import { Community as DbCommunity } from '@entity/Community'
import { gql } from 'graphql-request'
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {

View File

@ -1,7 +1,7 @@
import { IsNull } from '@dbTools/typeorm'
import { Community as DbCommunity } from '@entity/Community'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
// eslint-disable-next-line camelcase

View File

@ -3,7 +3,7 @@ import { ArgsType, Field, InputType } from 'type-graphql'
@InputType()
@ArgsType()
export default class AdminCreateContributionArgs {
export class AdminCreateContributionArgs {
@Field(() => String)
email: string

View File

@ -2,7 +2,7 @@ import { Decimal } from 'decimal.js-light'
import { ArgsType, Field, Int } from 'type-graphql'
@ArgsType()
export default class AdminUpdateContributionArgs {
export class AdminUpdateContributionArgs {
@Field(() => Int)
id: number

View File

@ -3,7 +3,7 @@ import { ArgsType, Field, InputType } from 'type-graphql'
@InputType()
@ArgsType()
export default class ContributionArgs {
export class ContributionArgs {
@Field(() => Decimal)
amount: Decimal

View File

@ -2,7 +2,7 @@ import { Decimal } from 'decimal.js-light'
import { ArgsType, Field, Int } from 'type-graphql'
@ArgsType()
export default class ContributionLinkArgs {
export class ContributionLinkArgs {
@Field(() => Decimal)
amount: Decimal

View File

@ -2,7 +2,7 @@ import { ArgsType, Field, Int, InputType } from 'type-graphql'
@InputType()
@ArgsType()
export default class ContributionMessageArgs {
export class ContributionMessageArgs {
@Field(() => Int)
contributionId: number

View File

@ -1,7 +1,7 @@
import { ArgsType, Field, Int } from 'type-graphql'
@ArgsType()
export default class CreateUserArgs {
export class CreateUserArgs {
@Field(() => String)
email: string

View File

@ -4,7 +4,7 @@ import { ArgsType, Field, Int } from 'type-graphql'
import { Order } from '@enum/Order'
@ArgsType()
export default class Paginated {
export class Paginated {
@Field(() => Int, { nullable: true })
currentPage?: number

View File

@ -1,9 +1,9 @@
import { ArgsType, Field, Int } from 'type-graphql'
import SearchUsersFilters from '@arg/SearchUsersFilters'
import { SearchUsersFilters } from '@arg/SearchUsersFilters'
@ArgsType()
export default class SearchUsersArgs {
export class SearchUsersArgs {
@Field(() => String)
searchText: string

View File

@ -1,7 +1,7 @@
import { Field, InputType } from 'type-graphql'
@InputType()
export default class SearchUsersFilters {
export class SearchUsersFilters {
@Field(() => Boolean, { nullable: true, defaultValue: null })
byActivated?: boolean | null

View File

@ -2,7 +2,7 @@ import { Decimal } from 'decimal.js-light'
import { ArgsType, Field } from 'type-graphql'
@ArgsType()
export default class TransactionLinkArgs {
export class TransactionLinkArgs {
@Field(() => Decimal)
amount: Decimal

View File

@ -2,7 +2,7 @@
import { Field, InputType } from 'type-graphql'
@InputType()
export default class TransactionLinkFilters {
export class TransactionLinkFilters {
@Field(() => Boolean, { nullable: true })
withDeleted?: boolean

View File

@ -2,7 +2,7 @@ import { Decimal } from 'decimal.js-light'
import { ArgsType, Field } from 'type-graphql'
@ArgsType()
export default class TransactionSendArgs {
export class TransactionSendArgs {
@Field(() => String)
identifier: string

View File

@ -1,7 +1,7 @@
import { ArgsType, Field, Int } from 'type-graphql'
@ArgsType()
export default class UnsecureLoginArgs {
export class UnsecureLoginArgs {
@Field(() => String)
email: string

View File

@ -1,7 +1,7 @@
import { ArgsType, Field, Int } from 'type-graphql'
@ArgsType()
export default class UpdateUserInfosArgs {
export class UpdateUserInfosArgs {
@Field({ nullable: true })
firstName?: string

View File

@ -10,9 +10,9 @@ import { INALIENABLE_RIGHTS } from '@/auth/INALIENABLE_RIGHTS'
import { decode, encode } from '@/auth/JWT'
import { RIGHTS } from '@/auth/RIGHTS'
import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
export const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
context.role = ROLE_UNAUTHORIZED // unauthorized user
// is rights an inalienable right?
@ -56,5 +56,3 @@ const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
context.setHeaders.push({ key: 'token', value: encode(decoded.gradidoID) })
return true
}
export default isAuthorized

View File

@ -2,7 +2,7 @@ import { ContributionLink as dbContributionLink } from '@entity/ContributionLink
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
@ObjectType()
export class ContributionLink {

View File

@ -2,7 +2,7 @@ import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import { User } from './User'

View File

@ -13,7 +13,7 @@ import { GraphQLError } from 'graphql'
import { cleanDB, testEnvironment, resetToken } from '@test/helpers'
import { logger } from '@test/testSetup'
import { EventType } from '@/event/Event'
import { EventType } from '@/event/Events'
import { userFactory } from '@/seeds/factory/user'
import {
login,

View File

@ -3,9 +3,8 @@ import { ContributionLink as DbContributionLink } from '@entity/ContributionLink
import { Decimal } from 'decimal.js-light'
import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql'
// TODO: this is a strange construct
import ContributionLinkArgs from '@arg/ContributionLinkArgs'
import Paginated from '@arg/Paginated'
import { ContributionLinkArgs } from '@arg/ContributionLinkArgs'
import { Paginated } from '@arg/Paginated'
import { Order } from '@enum/Order'
import { ContributionLink } from '@model/ContributionLink'
import { ContributionLinkList } from '@model/ContributionLinkList'
@ -15,9 +14,9 @@ import {
EVENT_ADMIN_CONTRIBUTION_LINK_CREATE,
EVENT_ADMIN_CONTRIBUTION_LINK_DELETE,
EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE,
} from '@/event/Event'
} from '@/event/Events'
import { Context, getUser } from '@/server/context'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import {
CONTRIBUTIONLINK_NAME_MAX_CHARS,

View File

@ -13,7 +13,7 @@ import { cleanDB, resetToken, testEnvironment } from '@test/helpers'
import { logger, i18n as localization } from '@test/testSetup'
import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants'
import { EventType } from '@/event/Event'
import { EventType } from '@/event/Events'
import { userFactory } from '@/seeds/factory/user'
import {
adminCreateContributionMessage,

View File

@ -6,8 +6,8 @@ import { User as DbUser } from '@entity/User'
import { UserContact as DbUserContact } from '@entity/UserContact'
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
import ContributionMessageArgs from '@arg/ContributionMessageArgs'
import Paginated from '@arg/Paginated'
import { ContributionMessageArgs } from '@arg/ContributionMessageArgs'
import { Paginated } from '@arg/Paginated'
import { ContributionStatus } from '@enum/ContributionStatus'
import { ContributionMessageType } from '@enum/MessageType'
import { Order } from '@enum/Order'
@ -18,9 +18,9 @@ import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants'
import {
EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE,
EVENT_CONTRIBUTION_MESSAGE_CREATE,
} from '@/event/Event'
} from '@/event/Events'
import { Context, getUser } from '@/server/context'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
@Resolver()
export class ContributionMessageResolver {

View File

@ -32,7 +32,7 @@ import {
sendContributionDeletedEmail,
sendContributionDeniedEmail,
} from '@/emails/sendEmailVariants'
import { EventType } from '@/event/Event'
import { EventType } from '@/event/Events'
import { creations } from '@/seeds/creation/index'
import { creationFactory } from '@/seeds/factory/creation'
import { userFactory } from '@/seeds/factory/user'

View File

@ -8,10 +8,10 @@ import { UserContact } from '@entity/UserContact'
import { Decimal } from 'decimal.js-light'
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs'
import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs'
import ContributionArgs from '@arg/ContributionArgs'
import Paginated from '@arg/Paginated'
import { AdminCreateContributionArgs } from '@arg/AdminCreateContributionArgs'
import { AdminUpdateContributionArgs } from '@arg/AdminUpdateContributionArgs'
import { ContributionArgs } from '@arg/ContributionArgs'
import { Paginated } from '@arg/Paginated'
import { ContributionStatus } from '@enum/ContributionStatus'
import { ContributionType } from '@enum/ContributionType'
import { ContributionMessageType } from '@enum/MessageType'
@ -38,9 +38,9 @@ import {
EVENT_ADMIN_CONTRIBUTION_DELETE,
EVENT_ADMIN_CONTRIBUTION_CONFIRM,
EVENT_ADMIN_CONTRIBUTION_DENY,
} from '@/event/Event'
} from '@/event/Events'
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
import { calculateDecay } from '@/util/decay'
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'

View File

@ -9,7 +9,7 @@ import { GraphQLError } from 'graphql'
import { testEnvironment, cleanDB } from '@test/helpers'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations'
import { queryOptIn } from '@/seeds/graphql/queries'

View File

@ -4,15 +4,15 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-graphql'
import Paginated from '@arg/Paginated'
import { Paginated } from '@arg/Paginated'
import { Order } from '@enum/Order'
import { GdtEntryList } from '@model/GdtEntryList'
import { apiGet, apiPost } from '@/apis/HttpRequest'
import { RIGHTS } from '@/auth/RIGHTS'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import { Context, getUser } from '@/server/context'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
@Resolver()
export class GdtResolver {

View File

@ -18,7 +18,7 @@ import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers'
import { logger } from '@test/testSetup'
import { EventType } from '@/event/Event'
import { EventType } from '@/event/Events'
import { creations } from '@/seeds/creation/index'
import { creationFactory } from '@/seeds/factory/creation'
import { transactionLinkFactory } from '@/seeds/factory/transactionLink'

View File

@ -9,9 +9,9 @@ import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql'
import Paginated from '@arg/Paginated'
import TransactionLinkArgs from '@arg/TransactionLinkArgs'
import TransactionLinkFilters from '@arg/TransactionLinkFilters'
import { Paginated } from '@arg/Paginated'
import { TransactionLinkArgs } from '@arg/TransactionLinkArgs'
import { TransactionLinkFilters } from '@arg/TransactionLinkFilters'
import { ContributionCycleType } from '@enum/ContributionCycleType'
import { ContributionStatus } from '@enum/ContributionStatus'
import { ContributionType } from '@enum/ContributionType'
@ -20,7 +20,7 @@ import { ContributionLink } from '@model/ContributionLink'
import { Decay } from '@model/Decay'
import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink'
import { User } from '@model/User'
import QueryLinkResult from '@union/QueryLinkResult'
import { QueryLinkResult } from '@union/QueryLinkResult'
import { RIGHTS } from '@/auth/RIGHTS'
import {
@ -28,9 +28,9 @@ import {
EVENT_TRANSACTION_LINK_CREATE,
EVENT_TRANSACTION_LINK_DELETE,
EVENT_TRANSACTION_LINK_REDEEM,
} from '@/event/Event'
} from '@/event/Events'
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
import { calculateDecay } from '@/util/decay'
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
@ -39,7 +39,7 @@ import { calculateBalance } from '@/util/validate'
import { executeTransaction } from './TransactionResolver'
import { getUserCreation, validateContribution } from './util/creations'
import { getLastTransaction } from './util/getLastTransaction'
import transactionLinkList from './util/transactionLinkList'
import { transactionLinkList } from './util/transactionLinkList'
// TODO: do not export, test it inside the resolver
export const transactionLinkCode = (date: Date): string => {

View File

@ -14,7 +14,7 @@ import { GraphQLError } from 'graphql'
import { cleanDB, testEnvironment } from '@test/helpers'
import { logger } from '@test/testSetup'
import { EventType } from '@/event/Event'
import { EventType } from '@/event/Events'
import { userFactory } from '@/seeds/factory/user'
import {
confirmContribution,

View File

@ -9,14 +9,13 @@ import { User as dbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
import Paginated from '@arg/Paginated'
import TransactionSendArgs from '@arg/TransactionSendArgs'
import { Paginated } from '@arg/Paginated'
import { TransactionSendArgs } from '@arg/TransactionSendArgs'
import { Order } from '@enum/Order'
import { TransactionTypeId } from '@enum/TransactionTypeId'
import { Transaction } from '@model/Transaction'
import { TransactionList } from '@model/TransactionList'
import { User } from '@model/User'
import { TransactionRepository } from '@repository/Transaction'
import { TransactionLinkRepository } from '@repository/TransactionLink'
import { RIGHTS } from '@/auth/RIGHTS'
@ -24,9 +23,9 @@ import {
sendTransactionLinkRedeemedEmail,
sendTransactionReceivedEmail,
} from '@/emails/sendEmailVariants'
import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Event'
import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Events'
import { Context, getUser } from '@/server/context'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
import { communityUser } from '@/util/communityUser'
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
@ -37,6 +36,7 @@ import { BalanceResolver } from './BalanceResolver'
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
import { findUserByIdentifier } from './util/findUserByIdentifier'
import { getLastTransaction } from './util/getLastTransaction'
import { getTransactionList } from './util/getTransactionList'
export const executeTransaction = async (
amount: Decimal,
@ -209,8 +209,7 @@ export class TransactionResolver {
// find transactions
// first page can contain 26 due to virtual decay transaction
const offset = (currentPage - 1) * pageSize
const transactionRepository = getCustomRepository(TransactionRepository)
const [userTransactions, userTransactionsCount] = await transactionRepository.findByUserPaged(
const [userTransactions, userTransactionsCount] = await getTransactionList(
user.id,
pageSize,
offset,
@ -283,7 +282,7 @@ export class TransactionResolver {
}
// transactions
userTransactions.forEach((userTransaction) => {
userTransactions.forEach((userTransaction: dbTransaction) => {
const linkedUser =
userTransaction.typeId === TransactionTypeId.CREATION
? communityUser

View File

@ -20,13 +20,13 @@ import { ContributionLink } from '@model/ContributionLink'
import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers'
import { logger, i18n as localization } from '@test/testSetup'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import {
sendAccountActivationEmail,
sendAccountMultiRegistrationEmail,
sendResetPasswordEmail,
} from '@/emails/sendEmailVariants'
import { EventType } from '@/event/Event'
import { EventType } from '@/event/Events'
import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils'
import { encryptPassword } from '@/password/PasswordEncryptor'
import { contributionLinkFactory } from '@/seeds/factory/contributionLink'

View File

@ -21,11 +21,11 @@ import {
} from 'type-graphql'
import { v4 as uuidv4 } from 'uuid'
import CreateUserArgs from '@arg/CreateUserArgs'
import Paginated from '@arg/Paginated'
import SearchUsersArgs from '@arg/SearchUsersArgs'
import UnsecureLoginArgs from '@arg/UnsecureLoginArgs'
import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs'
import { CreateUserArgs } from '@arg/CreateUserArgs'
import { Paginated } from '@arg/Paginated'
import { SearchUsersArgs } from '@arg/SearchUsersArgs'
import { UnsecureLoginArgs } from '@arg/UnsecureLoginArgs'
import { UpdateUserInfosArgs } from '@arg/UpdateUserInfosArgs'
import { OptInType } from '@enum/OptInType'
import { Order } from '@enum/Order'
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
@ -38,7 +38,7 @@ import { UserRepository } from '@repository/User'
import { klicktippSignIn } from '@/apis/KlicktippController'
import { encode } from '@/auth/JWT'
import { RIGHTS } from '@/auth/RIGHTS'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import {
sendAccountActivationEmail,
sendAccountMultiRegistrationEmail,
@ -59,12 +59,12 @@ import {
EVENT_ADMIN_USER_ROLE_SET,
EVENT_ADMIN_USER_DELETE,
EVENT_ADMIN_USER_UNDELETE,
} from '@/event/Event'
} from '@/event/Events'
import { klicktippNewsletterStateMiddleware } from '@/middleware/klicktippMiddleware'
import { isValidPassword } from '@/password/EncryptorUtils'
import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor'
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
import { communityDbUser } from '@/util/communityUser'
import { hasElopageBuys } from '@/util/hasElopageBuys'

View File

@ -8,7 +8,7 @@ import { Decimal } from 'decimal.js-light'
import { OpenCreation } from '@model/OpenCreation'
import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
interface CreationMap {

View File

@ -2,7 +2,7 @@ import { User as DbUser } from '@entity/User'
import { UserContact as DbUserContact } from '@entity/UserContact'
import { validate, version } from 'uuid'
import LogError from '@/server/LogError'
import { LogError } from '@/server/LogError'
export const findUserByIdentifier = async (identifier: string): Promise<DbUser> => {
let user: DbUser | undefined

View File

@ -0,0 +1,20 @@
import { Transaction as DbTransaction } from '@entity/Transaction'
import { Order } from '@enum/Order'
export const getTransactionList = async (
userId: number,
limit: number,
offset: number,
order: Order,
): Promise<[DbTransaction[], number]> => {
return DbTransaction.findAndCount({
where: {
userId,
},
order: { balanceDate: order, id: order },
relations: ['previousTransaction'],
skip: offset,
take: limit,
})
}

View File

@ -2,14 +2,14 @@ import { MoreThan } from '@dbTools/typeorm'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { User as DbUser } from '@entity/User'
import Paginated from '@arg/Paginated'
import TransactionLinkFilters from '@arg/TransactionLinkFilters'
import { Paginated } from '@arg/Paginated'
import { TransactionLinkFilters } from '@arg/TransactionLinkFilters'
import { Order } from '@enum/Order'
import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink'
import { User } from '@/graphql/model/User'
export default async function transactionLinkList(
export async function transactionLinkList(
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
filters: TransactionLinkFilters | null,
user: DbUser,

View File

@ -2,7 +2,7 @@
import { Decimal } from 'decimal.js-light'
import { GraphQLScalarType, Kind } from 'graphql'
const DecimalType = new GraphQLScalarType({
export const DecimalScalar = new GraphQLScalarType({
name: 'Decimal',
description: 'The `Decimal` scalar type to represent currency values',
@ -22,5 +22,3 @@ const DecimalType = new GraphQLScalarType({
return new Decimal(ast.value)
},
})
export default DecimalType

View File

@ -4,15 +4,13 @@ import { Decimal } from 'decimal.js-light'
import { GraphQLSchema } from 'graphql'
import { buildSchema } from 'type-graphql'
import isAuthorized from './directive/isAuthorized'
import DecimalScalar from './scalar/Decimal'
import { isAuthorized } from './directive/isAuthorized'
import { DecimalScalar } from './scalar/Decimal'
const schema = async (): Promise<GraphQLSchema> => {
export const schema = async (): Promise<GraphQLSchema> => {
return buildSchema({
resolvers: [path.join(__dirname, 'resolver', `!(*.test).{js,ts}`)],
authChecker: isAuthorized,
scalarsMap: [{ type: Decimal, scalar: DecimalScalar }],
})
}
export default schema

View File

@ -3,7 +3,7 @@ import { createUnionType } from 'type-graphql'
import { ContributionLink } from '@model/ContributionLink'
import { TransactionLink } from '@model/TransactionLink'
export default createUnionType({
export const QueryLinkResult = createUnionType({
name: 'QueryLinkResult', // the name of the GraphQL union
types: () => [TransactionLink, ContributionLink] as const, // function that returns tuple of object types classes
})

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import CONFIG from './config'
import { CONFIG } from './config'
import { startValidateCommunities } from './federation/validateCommunities'
import createServer from './server/createServer'
import { createServer } from './server/createServer'
async function main() {
const { app } = await createServer()

View File

@ -8,7 +8,7 @@ import { MiddlewareFn } from 'type-graphql'
import { KlickTipp } from '@model/KlickTipp'
import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
import { klickTippLogger as logger } from '@/server/logger'
// export const klicktippRegistrationMiddleware: MiddlewareFn = async (

View File

@ -6,8 +6,8 @@ import { User } from '@entity/User'
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
import CONFIG from '@/config'
import LogError from '@/server/LogError'
import { CONFIG } from '@/config'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs

View File

@ -9,8 +9,8 @@ import { entities } from '@entity/index'
import { createTestClient } from 'apollo-server-testing'
import { name, internet, datatype } from 'faker'
import CONFIG from '@/config'
import createServer from '@/server/createServer'
import { CONFIG } from '@/config'
import { createServer } from '@/server/createServer'
import { backendLogger as logger } from '@/server/logger'
import { contributionLinks } from './contributionLink/index'

View File

@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { logger } from '@test/testSetup'
import LogError from './LogError'
import { LogError } from './LogError'
describe('LogError', () => {
it('logs an Error when created', () => {

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { backendLogger as logger } from './logger'
export default class LogError extends Error {
export class LogError extends Error {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(msg: string, ...details: any[]) {
super(msg)

View File

@ -5,7 +5,7 @@ import { Decimal } from 'decimal.js-light'
import { Role } from '@/auth/Role'
import LogError from './LogError'
import { LogError } from './LogError'
export interface Context {
token: string | null
@ -20,7 +20,7 @@ export interface Context {
sumHoldAvailableAmount?: Decimal
}
const context = (args: ExpressContext): Context => {
export const context = (args: ExpressContext): Context => {
const authorization = args.req.headers.authorization
const clientTimezoneOffset = args.req.headers.clienttimezoneoffset
const context: Context = {
@ -50,5 +50,3 @@ export const getClientTimezoneOffset = (context: Context): number => {
}
throw new LogError('No valid client time zone offset in context')
}
export default context

View File

@ -1,8 +1,8 @@
import cors from 'cors'
import corsLib from 'cors'
const corsOptions = {
origin: '*',
exposedHeaders: ['token'],
}
export default cors(corsOptions)
export const cors = corsLib(corsOptions)

View File

@ -6,24 +6,24 @@ import { ApolloServer } from 'apollo-server-express'
import express, { Express, json, urlencoded } from 'express'
import { Logger } from 'log4js'
import CONFIG from '@/config'
import schema from '@/graphql/schema'
import connection from '@/typeorm/connection'
import { CONFIG } from '@/config'
import { schema } from '@/graphql/schema'
import { connection } from '@/typeorm/connection'
import { checkDBVersion } from '@/typeorm/DBVersion'
import { elopageWebhook } from '@/webhook/elopage'
import serverContext from './context'
import cors from './cors'
import { context as serverContext } from './context'
import { cors } from './cors'
import { i18n } from './localization'
import { apolloLogger } from './logger'
import plugins from './plugins'
import { plugins } from './plugins'
// TODO implement
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
type ServerDef = { apollo: ApolloServer; app: Express; con: Connection }
const createServer = async (
export const createServer = async (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
context: any = serverContext,
logger: Logger = apolloLogger,
@ -81,5 +81,3 @@ const createServer = async (
return { apollo, app, con }
}
export default createServer

View File

@ -5,7 +5,7 @@ import { readFileSync } from 'fs'
import { configure, getLogger } from 'log4js'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
const options = JSON.parse(readFileSync(CONFIG.LOG4JS_CONFIG, 'utf-8'))

View File

@ -60,8 +60,6 @@ ${JSON.stringify(requestContext.response.errors, null, 2)}`)
},
}
const plugins =
export const plugins =
// eslint-disable-next-line n/no-process-env
process.env.NODE_ENV === 'development' ? [setHeadersPlugin] : [setHeadersPlugin, logPlugin]
export default plugins

View File

@ -3,9 +3,9 @@
import { Connection, createConnection, FileLogger } from '@dbTools/typeorm'
import { entities } from '@entity/index'
import CONFIG from '@/config'
import { CONFIG } from '@/config'
const connection = async (): Promise<Connection | null> => {
export const connection = async (): Promise<Connection | null> => {
try {
return createConnection({
name: 'default',
@ -31,5 +31,3 @@ const connection = async (): Promise<Connection | null> => {
return null
}
}
export default connection

View File

@ -1,28 +0,0 @@
import { EntityRepository, Repository } from '@dbTools/typeorm'
import { Transaction } from '@entity/Transaction'
import { Order } from '@enum/Order'
@EntityRepository(Transaction)
export class TransactionRepository extends Repository<Transaction> {
findByUserPaged(
userId: number,
limit: number,
offset: number,
order: Order,
): Promise<[Transaction[], number]> {
const query = this.createQueryBuilder('userTransaction')
.leftJoinAndSelect(
'userTransaction.previousTransaction',
'transaction',
'userTransaction.previous = transaction.id',
)
.where('userTransaction.userId = :userId', { userId })
return query
.orderBy('userTransaction.balanceDate', order)
.limit(limit)
.offset(offset)
.getManyAndCount()
}
}

View File

@ -1,7 +1,7 @@
import { Brackets, EntityRepository, IsNull, Not, Repository } from '@dbTools/typeorm'
import { User as DbUser } from '@entity/User'
import SearchUsersFilters from '@/graphql/arg/SearchUsersFilters'
import { SearchUsersFilters } from '@/graphql/arg/SearchUsersFilters'
@EntityRepository(DbUser)
export class UserRepository extends Repository<DbUser> {

View File

@ -2,8 +2,8 @@ import { Decimal } from 'decimal.js-light'
import { Decay } from '@model/Decay'
import CONFIG from '@/config'
import LogError from '@/server/LogError'
import { CONFIG } from '@/config'
import { LogError } from '@/server/LogError'
// TODO: externalize all those definitions and functions into an external decay library

Some files were not shown because too many files have changed in this diff Show More