diff --git a/backend/.env.template b/backend/.env.template index 4d7ae42d2..6fe5b6b18 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -31,8 +31,6 @@ JWT_SECRET="b/&&7b78BF&fv/Vd" JWT_EXPIRES="2y" MAPBOX_TOKEN="pk.eyJ1IjoiYnVzZmFrdG9yIiwiYSI6ImNraDNiM3JxcDBhaWQydG1uczhpZWtpOW4ifQ.7TNRTO-o9aK1Y6MyW_Nd4g" -PRIVATE_KEY_PASSPHRASE="a7dsf78sadg87ad87sfagsadg78" - SENTRY_DSN_BACKEND= COMMIT= PUBLIC_REGISTRATION=false diff --git a/backend/.gitignore b/backend/.gitignore index 833f7e34e..0399b3220 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -3,7 +3,7 @@ node_modules/ .vscode .idea yarn-error.log -build/* +build/ coverage.lcov .nyc_output/ public/uploads/* diff --git a/backend/src/config/config.ts b/backend/src/config/config.ts new file mode 100644 index 000000000..b3c74b835 --- /dev/null +++ b/backend/src/config/config.ts @@ -0,0 +1,163 @@ +/* eslint-disable n/no-process-env */ +import { config } from 'dotenv' + +// Load env file +config() + +// Use Cypress env or process.env +declare let Cypress: { env: () => Record } | undefined +const env = typeof Cypress !== 'undefined' ? Cypress.env() : process.env + +const toNumber = (env: string | undefined): number | undefined => { + const number = Number(env) + return isNaN(number) ? undefined : number +} + +const environment = { + NODE_ENV: env.NODE_ENV ?? process.env.NODE_ENV, + DEBUG: env.NODE_ENV !== 'production' && env.DEBUG, + TEST: env.NODE_ENV === 'test', + PRODUCTION: env.NODE_ENV === 'production', + // used for staging environments if 'PRODUCTION=true' and 'PRODUCTION_DB_CLEAN_ALLOW=true' + PRODUCTION_DB_CLEAN_ALLOW: env.PRODUCTION_DB_CLEAN_ALLOW === 'true' || false, // default = false + DISABLED_MIDDLEWARES: env.DISABLED_MIDDLEWARES?.split(',') ?? [], +} + +const server = { + CLIENT_URI: env.CLIENT_URI ?? 'http://localhost:3000', + GRAPHQL_URI: env.GRAPHQL_URI ?? 'http://localhost:4000', + JWT_EXPIRES: env.JWT_EXPIRES ?? '7d', + JWT_SECRET: env.JWT_SECRET, + MAPBOX_TOKEN: + env.MAPBOX_TOKEN ?? + 'pk.eyJ1IjoiYnVzZmFrdG9yIiwiYSI6ImNraDNiM3JxcDBhaWQydG1uczhpZWtpOW4ifQ.7TNRTO-o9aK1Y6MyW_Nd4g', +} + +const hasDKIMData = env.SMTP_DKIM_DOMAINNAME && env.SMTP_DKIM_KEYSELECTOR && env.SMTP_DKIM_PRIVATKEY + +const smtp = { + SMTP_HOST: env.SMTP_HOST, + SMTP_PORT: env.SMTP_PORT, + SMTP_IGNORE_TLS: env.SMTP_IGNORE_TLS !== 'false', // default = true + SMTP_SECURE: env.SMTP_SECURE === 'true', + SMTP_USERNAME: env.SMTP_USERNAME, + SMTP_PASSWORD: env.SMTP_PASSWORD, + SMTP_DKIM_DOMAINNAME: hasDKIMData && env.SMTP_DKIM_DOMAINNAME, + SMTP_DKIM_KEYSELECTOR: hasDKIMData && env.SMTP_DKIM_KEYSELECTOR, + // PEM format: https://docs.progress.com/bundle/datadirect-hybrid-data-pipeline-installation-46/page/PEM-file-format.html + SMTP_DKIM_PRIVATKEY: hasDKIMData && env.SMTP_DKIM_PRIVATKEY, + SMTP_MAX_CONNECTIONS: env.SMTP_MAX_CONNECTIONS ?? 5, + SMTP_MAX_MESSAGES: env.SMTP_MAX_MESSAGES ?? 100, +} + +const neo4j = { + NEO4J_URI: env.NEO4J_URI ?? 'bolt://localhost:7687', + NEO4J_USERNAME: env.NEO4J_USERNAME ?? 'neo4j', + NEO4J_PASSWORD: env.NEO4J_PASSWORD ?? 'neo4j', +} + +const sentry = { + SENTRY_DSN_BACKEND: env.SENTRY_DSN_BACKEND, + COMMIT: env.COMMIT, +} + +const redis = { + REDIS_DOMAIN: env.REDIS_DOMAIN, + REDIS_PORT: toNumber(env.REDIS_PORT), + REDIS_PASSWORD: env.REDIS_PASSWORD, +} + +const s3 = { + AWS_ACCESS_KEY_ID: env.AWS_ACCESS_KEY_ID, + AWS_SECRET_ACCESS_KEY: env.AWS_SECRET_ACCESS_KEY, + AWS_ENDPOINT: env.AWS_ENDPOINT, + AWS_REGION: env.AWS_REGION, + AWS_BUCKET: env.AWS_BUCKET ?? '', + S3_CONFIGURED: + env.AWS_ACCESS_KEY_ID && + env.AWS_SECRET_ACCESS_KEY && + env.AWS_ENDPOINT && + env.AWS_REGION && + env.AWS_BUCKET, +} + +const logos = { + LOGO_HEADER_PATH: '/img/custom/logo-horizontal.svg', + LOGO_SIGNUP_PATH: '/img/custom/logo-squared.svg', + LOGO_WELCOME_PATH: '/img/custom/logo-squared.svg', + LOGO_LOGOUT_PATH: '/img/custom/logo-squared.svg', + LOGO_PASSWORD_RESET_PATH: '/img/custom/logo-squared.svg', + LOGO_MAINTENACE_RESET_PATH: '/img/custom/logo-squared.svg', +} + +const emails = { + EMAIL_DEFAULT_SENDER: env.EMAIL_DEFAULT_SENDER ?? 'devops@ocelot.social', + SUPPORT_EMAIL: env.SUPPORT_EMAIL ?? 'devops@ocelot.social', + // MODERATION_EMAIL: 'devops@ocelot.social', +} + +const metadata = { + APPLICATION_NAME: env.APPLICATION_NAME ?? 'ocelot.social', + APPLICATION_SHORT_NAME: env.APPLICATION_SHORT_NAME ?? 'ocelot.social', + APPLICATION_DESCRIPTION: env.APPLICATION_DESCRIPTION ?? 'ocelot.social Community Network', + COOKIE_NAME: env.COOKIE_NAME ?? 'ocelot-social-token', + ORGANIZATION_NAME: env.ORGANIZATION_NAME ?? 'ocelot.social Community', + ORGANIZATION_JURISDICTION: env.ORGANIZATION_JURISDICTION ?? 'City of Angels', + THEME_COLOR: env.THEME_COLOR ?? 'rgb(23, 181, 63)', // $color-primary – as the main color in general. e.g. the color in the background of the app that is visible behind the transparent iPhone status bar to name one use case, or the current color of SVGs to name another use case +} + +const badges = { + TROPHY_BADGES_SELECTED_MAX: toNumber(env.TROPHY_BADGES_SELECTED_MAX) ?? 9, +} + +const groups = { + DESCRIPTION_WITHOUT_HTML_LENGTH_MIN: env.DESCRIPTION_WITHOUT_HTML_LENGTH_MIN ?? 3, // with removed HTML tags + DESCRIPTION_EXCERPT_HTML_LENGTH: env.DESCRIPTION_EXCERPT_HTML_LENGTH ?? 250, // with removed HTML tags +} + +const registration = { + NONCE_LENGTH: toNumber(env.NONCE_LENGTH) ?? 5, + INVITE_CODE_LENGTH: toNumber(env.INVITE_CODE_LENGTH) ?? 6, + REGISTRATION_LAYOUT: env.REGISTRATION_LAYOUT ?? 'no-header', +} + +const categories = { + CATEGORIES_MIN: env.CATEGORIES_MIN ?? 1, + CATEGORIES_MAX: env.CATEGORIES_MAX ?? 3, +} + +const options = { + PUBLIC_REGISTRATION: env.PUBLIC_REGISTRATION === 'true' || false, + INVITE_REGISTRATION: env.INVITE_REGISTRATION !== 'false', // default = true + CATEGORIES_ACTIVE: process.env.CATEGORIES_ACTIVE === 'true' || false, + // ATTENTION: the following links have to be defined even for internal pages with full URLs as example like 'https://staging.ocelot.social/support', because they are used in e-mails! + ORGANIZATION_URL: env.ORGANIZATION_URL ?? 'https://ocelot.social', + SUPPORT_URL: env.SUPPORT_URL ?? 'https://ocelot.social', +} + +// Check if all required configs are present +const required = ['JWT_SECRET'] +required.forEach((entry) => { + // eslint-disable-next-line security/detect-object-injection + if (!env[entry]) { + throw new Error(`ERROR: "${entry}" env variable is missing.`) + } +}) + +export default { + ...environment, + ...server, + ...smtp, + ...neo4j, + ...sentry, + ...redis, + ...s3, + ...options, + ...logos, + ...emails, + ...metadata, + ...badges, + ...groups, + ...registration, + ...categories, +} diff --git a/backend/src/config/emails.ts b/backend/src/config/emails.ts deleted file mode 100644 index 34daaecb0..000000000 --- a/backend/src/config/emails.ts +++ /dev/null @@ -1,8 +0,0 @@ -// this file is duplicated in `backend/src/config/` and `webapp/constants/` and replaced on rebranding by https://github.com/Ocelot-Social-Community/Ocelot-Social-Deploy-Rebranding/tree/master/branding/constants/ -export default { - SUPPORT_EMAIL: 'devops@ocelot.social', - MODERATION_EMAIL: 'devops@ocelot.social', - // ATTENTION: the following links have to be defined even for internal pages with full URLs as example like 'https://staging.ocelot.social/support', because they are used in e-mails! - ORGANIZATION_LINK: 'https://ocelot.social', - SUPPORT_LINK: 'https://ocelot.social', -} diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts deleted file mode 100644 index 9b82299ae..000000000 --- a/backend/src/config/index.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable n/no-process-env */ -import { config } from 'dotenv' - -import emails from './emails' -import metadata from './metadata' - -// Load env file -config() - -// Use Cypress env or process.env -// eslint-disable-next-line @typescript-eslint/no-explicit-any -declare let Cypress: any | undefined -const env = typeof Cypress !== 'undefined' ? Cypress.env() : process.env - -const environment = { - NODE_ENV: env.NODE_ENV || process.env.NODE_ENV, - DEBUG: env.NODE_ENV !== 'production' && env.DEBUG, - TEST: env.NODE_ENV === 'test', - PRODUCTION: env.NODE_ENV === 'production', - // used for staging enviroments if 'PRODUCTION=true' and 'PRODUCTION_DB_CLEAN_ALLOW=true' - PRODUCTION_DB_CLEAN_ALLOW: env.PRODUCTION_DB_CLEAN_ALLOW === 'true' || false, // default = false - DISABLED_MIDDLEWARES: ['test', 'development'].includes(env.NODE_ENV as string) - ? (env.DISABLED_MIDDLEWARES?.split(',') ?? []) - : [], -} - -const required = { - MAPBOX_TOKEN: env.MAPBOX_TOKEN, - JWT_SECRET: env.JWT_SECRET, - PRIVATE_KEY_PASSPHRASE: env.PRIVATE_KEY_PASSPHRASE, -} - -const server = { - CLIENT_URI: env.CLIENT_URI || 'http://localhost:3000', - GRAPHQL_URI: env.GRAPHQL_URI || 'http://localhost:4000', - JWT_EXPIRES: env.JWT_EXPIRES || '2y', -} - -const hasDKIMData = env.SMTP_DKIM_DOMAINNAME && env.SMTP_DKIM_KEYSELECTOR && env.SMTP_DKIM_PRIVATKEY - -const smtp = { - SMTP_HOST: env.SMTP_HOST, - SMTP_PORT: env.SMTP_PORT, - SMTP_IGNORE_TLS: env.SMTP_IGNORE_TLS !== 'false', // default = true - SMTP_SECURE: env.SMTP_SECURE === 'true', - SMTP_USERNAME: env.SMTP_USERNAME, - SMTP_PASSWORD: env.SMTP_PASSWORD, - SMTP_DKIM_DOMAINNAME: hasDKIMData && env.SMTP_DKIM_DOMAINNAME, - SMTP_DKIM_KEYSELECTOR: hasDKIMData && env.SMTP_DKIM_KEYSELECTOR, - // PEM format: https://docs.progress.com/bundle/datadirect-hybrid-data-pipeline-installation-46/page/PEM-file-format.html - SMTP_DKIM_PRIVATKEY: hasDKIMData && env.SMTP_DKIM_PRIVATKEY.replace(/\\n/g, '\n'), // replace all "\n" in .env string by real line break - SMTP_MAX_CONNECTIONS: env.SMTP_MAX_CONNECTIONS || 5, - SMTP_MAX_MESSAGES: env.SMTP_MAX_MESSAGES || 100, -} - -const neo4j = { - NEO4J_URI: env.NEO4J_URI || 'bolt://localhost:7687', - NEO4J_USERNAME: env.NEO4J_USERNAME || 'neo4j', - NEO4J_PASSWORD: env.NEO4J_PASSWORD || 'neo4j', -} - -const sentry = { - SENTRY_DSN_BACKEND: env.SENTRY_DSN_BACKEND, - COMMIT: env.COMMIT, -} - -const redis = { - REDIS_DOMAIN: env.REDIS_DOMAIN, - REDIS_PORT: env.REDIS_PORT, - REDIS_PASSWORD: env.REDIS_PASSWORD, -} - -const s3 = { - AWS_ACCESS_KEY_ID: env.AWS_ACCESS_KEY_ID, - AWS_SECRET_ACCESS_KEY: env.AWS_SECRET_ACCESS_KEY, - AWS_ENDPOINT: env.AWS_ENDPOINT, - AWS_REGION: env.AWS_REGION, - AWS_BUCKET: env.AWS_BUCKET, - S3_CONFIGURED: - env.AWS_ACCESS_KEY_ID && - env.AWS_SECRET_ACCESS_KEY && - env.AWS_ENDPOINT && - env.AWS_REGION && - env.AWS_BUCKET, -} - -const options = { - EMAIL_DEFAULT_SENDER: env.EMAIL_DEFAULT_SENDER, - SUPPORT_URL: emails.SUPPORT_LINK, - APPLICATION_NAME: metadata.APPLICATION_NAME, - ORGANIZATION_URL: emails.ORGANIZATION_LINK, - PUBLIC_REGISTRATION: env.PUBLIC_REGISTRATION === 'true' || false, - INVITE_REGISTRATION: env.INVITE_REGISTRATION !== 'false', // default = true - CATEGORIES_ACTIVE: process.env.CATEGORIES_ACTIVE === 'true' || false, -} - -// Check if all required configs are present -Object.entries(required).map((entry) => { - if (!entry[1]) { - throw new Error(`ERROR: "${entry[0]}" env variable is missing.`) - } - return entry -}) - -export default { - ...environment, - ...server, - ...required, - ...smtp, - ...neo4j, - ...sentry, - ...redis, - ...s3, - ...options, -} diff --git a/backend/src/config/logos.ts b/backend/src/config/logos.ts deleted file mode 100644 index 41b83b30c..000000000 --- a/backend/src/config/logos.ts +++ /dev/null @@ -1,10 +0,0 @@ -// this file is duplicated in `backend/src/config/logos` and `webapp/constants/logos.js` and replaced on rebranding -// this are the paths in the webapp -export default { - LOGO_HEADER_PATH: '/img/custom/logo-horizontal.svg', - LOGO_SIGNUP_PATH: '/img/custom/logo-squared.svg', - LOGO_WELCOME_PATH: '/img/custom/logo-squared.svg', - LOGO_LOGOUT_PATH: '/img/custom/logo-squared.svg', - LOGO_PASSWORD_RESET_PATH: '/img/custom/logo-squared.svg', - LOGO_MAINTENACE_RESET_PATH: '/img/custom/logo-squared.svg', -} diff --git a/backend/src/config/metadata.ts b/backend/src/config/metadata.ts deleted file mode 100644 index 9c87818ae..000000000 --- a/backend/src/config/metadata.ts +++ /dev/null @@ -1,10 +0,0 @@ -// this file is duplicated in `backend/src/config/metadata` and `webapp/constants/metadata.js` and replaced on rebranding -export default { - APPLICATION_NAME: 'ocelot.social', - APPLICATION_SHORT_NAME: 'ocelot.social', - APPLICATION_DESCRIPTION: 'ocelot.social Community Network', - COOKIE_NAME: 'ocelot-social-token', - ORGANIZATION_NAME: 'ocelot.social Community', - ORGANIZATION_JURISDICTION: 'City of Angels', - THEME_COLOR: 'rgb(23, 181, 63)', // $color-primary – as the main color in general. e.g. the color in the background of the app that is visible behind the transparent iPhone status bar to name one use case, or the current color of SVGs to name another use case -} diff --git a/backend/src/constants/badges.ts b/backend/src/constants/badges.ts deleted file mode 100644 index bccebb39a..000000000 --- a/backend/src/constants/badges.ts +++ /dev/null @@ -1,2 +0,0 @@ -// this file is duplicated in `backend/src/constants/badges` and `webapp/constants/badges.js` -export const TROPHY_BADGES_SELECTED_MAX = 9 diff --git a/backend/src/constants/categories.ts b/backend/src/constants/categories.ts index 6365d268a..a2bf39489 100644 --- a/backend/src/constants/categories.ts +++ b/backend/src/constants/categories.ts @@ -1,7 +1,4 @@ // this file is duplicated in `backend/src/constants/metadata` and `webapp/constants/metadata.js` -export const CATEGORIES_MIN = 1 -export const CATEGORIES_MAX = 3 - export const categories = [ { icon: 'networking', diff --git a/backend/src/constants/groups.ts b/backend/src/constants/groups.ts deleted file mode 100644 index 6300afa35..000000000 --- a/backend/src/constants/groups.ts +++ /dev/null @@ -1,3 +0,0 @@ -// this file is duplicated in `backend/src/constants/group` and `webapp/constants/group.js` -export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 3 // with removed HTML tags -export const DESCRIPTION_EXCERPT_HTML_LENGTH = 250 // with removed HTML tags diff --git a/backend/src/constants/registration.ts b/backend/src/constants/registration.ts deleted file mode 100644 index 8ebb40573..000000000 --- a/backend/src/constants/registration.ts +++ /dev/null @@ -1,2 +0,0 @@ -// this file is duplicated in `backend/src/config/registration.ts` and `webapp/constants/registration.js` -export default {} diff --git a/backend/src/constants/registrationBranded.ts b/backend/src/constants/registrationBranded.ts deleted file mode 100644 index 2ce1d6965..000000000 --- a/backend/src/constants/registrationBranded.ts +++ /dev/null @@ -1,12 +0,0 @@ -// this file is duplicated in `backend/src/config/registrationBranded.ts` and `webapp/constants/registrationBranded.js` -import { merge } from 'lodash' - -import registration from '@constants/registration' - -const defaultRegistration = { - NONCE_LENGTH: 5, - INVITE_CODE_LENGTH: 6, - LAYOUT: 'no-header', -} - -export default merge(defaultRegistration, registration) diff --git a/backend/src/db/migrations-examples/20200312140328-bulk_upload_to_s3.ts b/backend/src/db/migrations-examples/20200312140328-bulk_upload_to_s3.ts index 0307a2e6e..f1d8ddad5 100644 --- a/backend/src/db/migrations-examples/20200312140328-bulk_upload_to_s3.ts +++ b/backend/src/db/migrations-examples/20200312140328-bulk_upload_to_s3.ts @@ -11,7 +11,7 @@ import path from 'node:path' import { S3 } from 'aws-sdk' import mime from 'mime-types' -import s3Configs from '@config/index' +import s3Configs from '@config/config' import { getDriver } from '@db/neo4j' export const description = ` diff --git a/backend/src/db/neo4j.ts b/backend/src/db/neo4j.ts index 5d084099a..c74eadd00 100644 --- a/backend/src/db/neo4j.ts +++ b/backend/src/db/neo4j.ts @@ -1,11 +1,8 @@ -/* eslint-disable @typescript-eslint/no-unsafe-argument */ - -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable import/no-named-as-default-member */ import neo4j, { Driver } from 'neo4j-driver' import Neode from 'neode' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import models from '@db/models/index' let driver: Driver diff --git a/backend/src/db/reset-with-migrations.ts b/backend/src/db/reset-with-migrations.ts index 78db831ce..991cad122 100644 --- a/backend/src/db/reset-with-migrations.ts +++ b/backend/src/db/reset-with-migrations.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/no-floating-promises */ /* eslint-disable n/no-process-exit */ -import CONFIG from '@config/index' +import CONFIG from '@config/config' import { cleanDatabase } from './factories' diff --git a/backend/src/db/reset.ts b/backend/src/db/reset.ts index a381799c6..27c6369d8 100644 --- a/backend/src/db/reset.ts +++ b/backend/src/db/reset.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/no-floating-promises */ /* eslint-disable n/no-process-exit */ -import CONFIG from '@config/index' +import CONFIG from '@config/config' import { cleanDatabase } from './factories' diff --git a/backend/src/db/seed.ts b/backend/src/db/seed.ts index 0e2c2c61d..4e5cade01 100644 --- a/backend/src/db/seed.ts +++ b/backend/src/db/seed.ts @@ -7,7 +7,7 @@ import { faker } from '@faker-js/faker' import { createTestClient } from 'apollo-server-testing' import sample from 'lodash/sample' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import { categories } from '@constants/categories' import { changeGroupMemberRoleMutation } from '@graphql/queries/changeGroupMemberRoleMutation' import { createCommentMutation } from '@graphql/queries/createCommentMutation' diff --git a/backend/src/graphql/resolvers/filter-posts.spec.ts b/backend/src/graphql/resolvers/filter-posts.spec.ts index c29b98365..c8e1c1a5b 100644 --- a/backend/src/graphql/resolvers/filter-posts.spec.ts +++ b/backend/src/graphql/resolvers/filter-posts.spec.ts @@ -3,7 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { createTestClient } from 'apollo-server-testing' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { createPostMutation } from '@graphql/queries/createPostMutation' diff --git a/backend/src/graphql/resolvers/groups.spec.ts b/backend/src/graphql/resolvers/groups.spec.ts index 664f57397..f38f47a20 100644 --- a/backend/src/graphql/resolvers/groups.spec.ts +++ b/backend/src/graphql/resolvers/groups.spec.ts @@ -5,7 +5,7 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { createTestClient } from 'apollo-server-testing' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { changeGroupMemberRoleMutation } from '@graphql/queries/changeGroupMemberRoleMutation' diff --git a/backend/src/graphql/resolvers/groups.ts b/backend/src/graphql/resolvers/groups.ts index 96d806bf8..0ea7670f8 100644 --- a/backend/src/graphql/resolvers/groups.ts +++ b/backend/src/graphql/resolvers/groups.ts @@ -8,9 +8,7 @@ import { UserInputError } from 'apollo-server' import { v4 as uuid } from 'uuid' -import CONFIG from '@config/index' -import { CATEGORIES_MIN, CATEGORIES_MAX } from '@constants/categories' -import { DESCRIPTION_WITHOUT_HTML_LENGTH_MIN } from '@constants/groups' +import CONFIG from '@config/config' import { removeHtmlTags } from '@middleware/helpers/cleanHtml' import Resolver, { @@ -138,16 +136,19 @@ export default { const { categoryIds } = params delete params.categoryIds params.locationName = params.locationName === '' ? null : params.locationName - if (CONFIG.CATEGORIES_ACTIVE && (!categoryIds || categoryIds.length < CATEGORIES_MIN)) { + if ( + CONFIG.CATEGORIES_ACTIVE && + (!categoryIds || categoryIds.length < CONFIG.CATEGORIES_MIN) + ) { throw new UserInputError('Too few categories!') } - if (CONFIG.CATEGORIES_ACTIVE && categoryIds && categoryIds.length > CATEGORIES_MAX) { + if (CONFIG.CATEGORIES_ACTIVE && categoryIds && categoryIds.length > CONFIG.CATEGORIES_MAX) { throw new UserInputError('Too many categories!') } if ( params.description === undefined || params.description === null || - removeHtmlTags(params.description).length < DESCRIPTION_WITHOUT_HTML_LENGTH_MIN + removeHtmlTags(params.description).length < CONFIG.DESCRIPTION_WITHOUT_HTML_LENGTH_MIN ) { throw new UserInputError('Description too short!') } @@ -208,16 +209,16 @@ export default { params.locationName = params.locationName === '' ? null : params.locationName if (CONFIG.CATEGORIES_ACTIVE && categoryIds) { - if (categoryIds.length < CATEGORIES_MIN) { + if (categoryIds.length < CONFIG.CATEGORIES_MIN) { throw new UserInputError('Too few categories!') } - if (categoryIds.length > CATEGORIES_MAX) { + if (categoryIds.length > CONFIG.CATEGORIES_MAX) { throw new UserInputError('Too many categories!') } } if ( params.description && - removeHtmlTags(params.description).length < DESCRIPTION_WITHOUT_HTML_LENGTH_MIN + removeHtmlTags(params.description).length < CONFIG.DESCRIPTION_WITHOUT_HTML_LENGTH_MIN ) { throw new UserInputError('Description too short!') } diff --git a/backend/src/graphql/resolvers/helpers/generateInviteCode.ts b/backend/src/graphql/resolvers/helpers/generateInviteCode.ts index 980af4593..ace850a7a 100644 --- a/backend/src/graphql/resolvers/helpers/generateInviteCode.ts +++ b/backend/src/graphql/resolvers/helpers/generateInviteCode.ts @@ -1,9 +1,9 @@ -import registrationConstants from '@constants/registrationBranded' +import CONFIG from '@config/config' export default function generateInviteCode() { // 6 random numbers in [ 0, 35 ] are 36 possible numbers (10 [0-9] + 26 [A-Z]) return Array.from( - { length: registrationConstants.INVITE_CODE_LENGTH }, + { length: CONFIG.INVITE_CODE_LENGTH }, (n: number = Math.floor(Math.random() * 36)) => { // n > 9: it is a letter (ASCII 65 is A) -> 10 + 55 = 65 // else: it is a number (ASCII 48 is 0) -> 0 + 48 = 48 diff --git a/backend/src/graphql/resolvers/helpers/generateNonce.ts b/backend/src/graphql/resolvers/helpers/generateNonce.ts index b7585b24f..cd4dcea49 100644 --- a/backend/src/graphql/resolvers/helpers/generateNonce.ts +++ b/backend/src/graphql/resolvers/helpers/generateNonce.ts @@ -1,9 +1,9 @@ -import registrationConstants from '@constants/registrationBranded' +import CONFIG from '@config/config' // TODO: why this is not used in resolver 'requestPasswordReset'? export default function generateNonce() { return Array.from( - { length: registrationConstants.NONCE_LENGTH }, + { length: CONFIG.NONCE_LENGTH }, (n: number = Math.floor(Math.random() * 10)) => { return String.fromCharCode(n + 48) }, diff --git a/backend/src/graphql/resolvers/images/images.ts b/backend/src/graphql/resolvers/images/images.ts index 2e76a7889..1d3290b11 100644 --- a/backend/src/graphql/resolvers/images/images.ts +++ b/backend/src/graphql/resolvers/images/images.ts @@ -15,7 +15,7 @@ import { S3 } from 'aws-sdk' import slug from 'slug' import { v4 as uuid } from 'uuid' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import { getDriver } from '@db/neo4j' // const widths = [34, 160, 320, 640, 1024] diff --git a/backend/src/graphql/resolvers/inviteCodes.spec.ts b/backend/src/graphql/resolvers/inviteCodes.spec.ts index f44721cc9..4943feca9 100644 --- a/backend/src/graphql/resolvers/inviteCodes.spec.ts +++ b/backend/src/graphql/resolvers/inviteCodes.spec.ts @@ -5,7 +5,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' -import registrationConstants from '@constants/registrationBranded' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getDriver } from '@db/neo4j' import createServer from '@src/server' @@ -115,9 +115,7 @@ describe('inviteCodes', () => { data: { GenerateInviteCode: { code: expect.stringMatching( - new RegExp( - `^[0-9A-Z]{${registrationConstants.INVITE_CODE_LENGTH},${registrationConstants.INVITE_CODE_LENGTH}}$`, - ), + new RegExp(`^[0-9A-Z]{${CONFIG.INVITE_CODE_LENGTH},${CONFIG.INVITE_CODE_LENGTH}}$`), ), expiresAt: null, createdAt: expect.any(String), @@ -141,9 +139,7 @@ describe('inviteCodes', () => { data: { GenerateInviteCode: { code: expect.stringMatching( - new RegExp( - `^[0-9A-Z]{${registrationConstants.INVITE_CODE_LENGTH},${registrationConstants.INVITE_CODE_LENGTH}}$`, - ), + new RegExp(`^[0-9A-Z]{${CONFIG.INVITE_CODE_LENGTH},${CONFIG.INVITE_CODE_LENGTH}}$`), ), expiresAt: nextWeek.toISOString(), createdAt: expect.any(String), diff --git a/backend/src/graphql/resolvers/observePosts.spec.ts b/backend/src/graphql/resolvers/observePosts.spec.ts index 76ad5b058..5b4e3c5e0 100644 --- a/backend/src/graphql/resolvers/observePosts.spec.ts +++ b/backend/src/graphql/resolvers/observePosts.spec.ts @@ -4,7 +4,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { createPostMutation } from '@graphql/queries/createPostMutation' diff --git a/backend/src/graphql/resolvers/passwordReset.spec.ts b/backend/src/graphql/resolvers/passwordReset.spec.ts index d5d08265c..89bebe46e 100644 --- a/backend/src/graphql/resolvers/passwordReset.spec.ts +++ b/backend/src/graphql/resolvers/passwordReset.spec.ts @@ -5,7 +5,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' -import registrationConstants from '@constants/registrationBranded' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import createServer from '@src/server' @@ -118,7 +118,7 @@ describe('passwordReset', () => { const resets = await getAllPasswordResets() const [reset] = resets const { nonce } = reset.properties - expect(nonce).toHaveLength(registrationConstants.NONCE_LENGTH) + expect(nonce).toHaveLength(CONFIG.NONCE_LENGTH) }) }) }) diff --git a/backend/src/graphql/resolvers/passwordReset.ts b/backend/src/graphql/resolvers/passwordReset.ts index f806f7249..7f1cd2b05 100644 --- a/backend/src/graphql/resolvers/passwordReset.ts +++ b/backend/src/graphql/resolvers/passwordReset.ts @@ -7,7 +7,7 @@ import bcrypt from 'bcryptjs' import { v4 as uuid } from 'uuid' -import registrationConstants from '@constants/registrationBranded' +import CONFIG from '@config/config' import createPasswordReset from './helpers/createPasswordReset' @@ -15,7 +15,7 @@ export default { Mutation: { requestPasswordReset: async (_parent, { email }, { driver }) => { // TODO: why this is generated differntly from 'backend/src/schema/resolvers/helpers/generateNonce.js'? - const nonce = uuid().substring(0, registrationConstants.NONCE_LENGTH) + const nonce = uuid().substring(0, CONFIG.NONCE_LENGTH) return createPasswordReset({ driver, nonce, email }) }, resetPassword: async (_parent, { email, nonce, newPassword }, { driver }) => { diff --git a/backend/src/graphql/resolvers/posts.spec.ts b/backend/src/graphql/resolvers/posts.spec.ts index 7574bef17..241db71b1 100644 --- a/backend/src/graphql/resolvers/posts.spec.ts +++ b/backend/src/graphql/resolvers/posts.spec.ts @@ -6,7 +6,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import Image from '@db/models/Image' import { getNeode, getDriver } from '@db/neo4j' diff --git a/backend/src/graphql/resolvers/posts.ts b/backend/src/graphql/resolvers/posts.ts index f981662ba..41268dc68 100644 --- a/backend/src/graphql/resolvers/posts.ts +++ b/backend/src/graphql/resolvers/posts.ts @@ -9,7 +9,7 @@ import { isEmpty } from 'lodash' import { neo4jgraphql } from 'neo4j-graphql-js' import { v4 as uuid } from 'uuid' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import { validateEventParams } from './helpers/events' import { filterForMutedUsers } from './helpers/filterForMutedUsers' diff --git a/backend/src/graphql/resolvers/postsInGroups.spec.ts b/backend/src/graphql/resolvers/postsInGroups.spec.ts index 7cb0bdc76..1225c3dd8 100644 --- a/backend/src/graphql/resolvers/postsInGroups.spec.ts +++ b/backend/src/graphql/resolvers/postsInGroups.spec.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { createTestClient } from 'apollo-server-testing' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { changeGroupMemberRoleMutation } from '@graphql/queries/changeGroupMemberRoleMutation' diff --git a/backend/src/graphql/resolvers/registration.spec.ts b/backend/src/graphql/resolvers/registration.spec.ts index ccf5a9e10..6606220c7 100644 --- a/backend/src/graphql/resolvers/registration.spec.ts +++ b/backend/src/graphql/resolvers/registration.spec.ts @@ -5,7 +5,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import EmailAddress from '@db/models/EmailAddress' import User from '@db/models/User' diff --git a/backend/src/graphql/resolvers/user_management.spec.ts b/backend/src/graphql/resolvers/user_management.spec.ts index 1029ab2b1..82413d5b3 100644 --- a/backend/src/graphql/resolvers/user_management.spec.ts +++ b/backend/src/graphql/resolvers/user_management.spec.ts @@ -10,7 +10,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' import jwt from 'jsonwebtoken' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import { categories } from '@constants/categories' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' diff --git a/backend/src/graphql/resolvers/users.ts b/backend/src/graphql/resolvers/users.ts index f549e79a3..eafc4185c 100644 --- a/backend/src/graphql/resolvers/users.ts +++ b/backend/src/graphql/resolvers/users.ts @@ -8,7 +8,7 @@ import { UserInputError, ForbiddenError } from 'apollo-server' import { neo4jgraphql } from 'neo4j-graphql-js' -import { TROPHY_BADGES_SELECTED_MAX } from '@constants/badges' +import CONFIG from '@config/config' import { getNeode } from '@db/neo4j' import { defaultTrophyBadge, defaultVerificationBadge } from './badges' @@ -394,9 +394,9 @@ export default { user: { id: userId }, } = context - if (slot >= TROPHY_BADGES_SELECTED_MAX || slot < 0) { + if (slot >= CONFIG.TROPHY_BADGES_SELECTED_MAX || slot < 0) { throw new Error( - `Invalid slot! There is only ${TROPHY_BADGES_SELECTED_MAX} badge-slots to fill`, + `Invalid slot! There is only ${CONFIG.TROPHY_BADGES_SELECTED_MAX} badge-slots to fill`, ) } @@ -539,7 +539,7 @@ export default { }) try { const badgesSelected = await query - const result = Array(TROPHY_BADGES_SELECTED_MAX).fill(defaultTrophyBadge) + const result = Array(CONFIG.TROPHY_BADGES_SELECTED_MAX).fill(defaultTrophyBadge) badgesSelected.map((record) => { result[record.get('slot')] = record.get('badge') return true diff --git a/backend/src/graphql/resolvers/users/location.ts b/backend/src/graphql/resolvers/users/location.ts index dc515e70d..e48cf0113 100644 --- a/backend/src/graphql/resolvers/users/location.ts +++ b/backend/src/graphql/resolvers/users/location.ts @@ -11,7 +11,7 @@ import { UserInputError } from 'apollo-server' import request from 'request' -import CONFIG from '@config/index' +import CONFIG from '@config/config' const fetch = (url) => { return new Promise((resolve, reject) => { diff --git a/backend/src/index.ts b/backend/src/index.ts index 3da4ec7ae..a65141688 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ -/* eslint-disable @typescript-eslint/no-unsafe-argument */ -import CONFIG from './config' + +import CONFIG from './config/config' import createServer from './server' const { server, httpServer } = createServer() diff --git a/backend/src/jwt/decode.ts b/backend/src/jwt/decode.ts index 0a433d38f..addf5448f 100644 --- a/backend/src/jwt/decode.ts +++ b/backend/src/jwt/decode.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import jwt from 'jsonwebtoken' -import CONFIG from '@config/index' +import CONFIG from '@config/config' export default async (driver, authorizationHeader) => { if (!authorizationHeader) return null diff --git a/backend/src/jwt/encode.spec.ts b/backend/src/jwt/encode.spec.ts index 8121118f3..3391b1863 100644 --- a/backend/src/jwt/encode.spec.ts +++ b/backend/src/jwt/encode.spec.ts @@ -3,7 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import jwt from 'jsonwebtoken' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import encode from './encode' diff --git a/backend/src/jwt/encode.ts b/backend/src/jwt/encode.ts index 742bf438b..5b3eafcdf 100644 --- a/backend/src/jwt/encode.ts +++ b/backend/src/jwt/encode.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import jwt from 'jsonwebtoken' -import CONFIG from '@config/index' +import CONFIG from '@config/config' // Generate an Access Token for the given User ID export default function encode(user) { diff --git a/backend/src/middleware/excerptMiddleware.ts b/backend/src/middleware/excerptMiddleware.ts index 7a865be90..2473aaf59 100644 --- a/backend/src/middleware/excerptMiddleware.ts +++ b/backend/src/middleware/excerptMiddleware.ts @@ -5,17 +5,20 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import trunc from 'trunc-html' -import { DESCRIPTION_EXCERPT_HTML_LENGTH } from '@constants/groups' +import CONFIG from '@config/config' export default { Mutation: { CreateGroup: async (resolve, root, args, context, info) => { - args.descriptionExcerpt = trunc(args.description, DESCRIPTION_EXCERPT_HTML_LENGTH).html + args.descriptionExcerpt = trunc(args.description, CONFIG.DESCRIPTION_EXCERPT_HTML_LENGTH).html return resolve(root, args, context, info) }, UpdateGroup: async (resolve, root, args, context, info) => { if (args.description) - args.descriptionExcerpt = trunc(args.description, DESCRIPTION_EXCERPT_HTML_LENGTH).html + args.descriptionExcerpt = trunc( + args.description, + CONFIG.DESCRIPTION_EXCERPT_HTML_LENGTH, + ).html return resolve(root, args, context, info) }, CreatePost: async (resolve, root, args, context, info) => { diff --git a/backend/src/middleware/helpers/email/sendMail.ts b/backend/src/middleware/helpers/email/sendMail.ts index a7d223f1c..b43fae747 100644 --- a/backend/src/middleware/helpers/email/sendMail.ts +++ b/backend/src/middleware/helpers/email/sendMail.ts @@ -7,7 +7,7 @@ import nodemailer from 'nodemailer' import { htmlToText } from 'nodemailer-html-to-text' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import { cleanHtml } from '@middleware/helpers/cleanHtml' const hasEmailConfig = CONFIG.SMTP_HOST && CONFIG.SMTP_PORT diff --git a/backend/src/middleware/helpers/email/templateBuilder.spec.ts b/backend/src/middleware/helpers/email/templateBuilder.spec.ts index 85608b55a..7e2cb1157 100644 --- a/backend/src/middleware/helpers/email/templateBuilder.spec.ts +++ b/backend/src/middleware/helpers/email/templateBuilder.spec.ts @@ -4,8 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-argument */ -import CONFIG from '@config/index' -import logosWebapp from '@config/logos' +import CONFIG from '@config/config' import { signupTemplate, @@ -17,7 +16,7 @@ import { } from './templateBuilder' const englishHint = 'English version below!' -const welcomeImageUrl = new URL(logosWebapp.LOGO_WELCOME_PATH, CONFIG.CLIENT_URI) +const welcomeImageUrl = new URL(CONFIG.LOGO_WELCOME_PATH, CONFIG.CLIENT_URI) const supportUrl = CONFIG.SUPPORT_URL.toString() let actionUrl, name, settingsUrl diff --git a/backend/src/middleware/helpers/email/templateBuilder.ts b/backend/src/middleware/helpers/email/templateBuilder.ts index ffceb49f6..fc3a3c959 100644 --- a/backend/src/middleware/helpers/email/templateBuilder.ts +++ b/backend/src/middleware/helpers/email/templateBuilder.ts @@ -6,21 +6,19 @@ /* eslint-disable import/no-namespace */ import mustache from 'mustache' -import CONFIG from '@config/index' -import logosWebapp from '@config/logos' -import metadata from '@config/metadata' +import CONFIG from '@config/config' import * as templates from './templates' import * as templatesDE from './templates/de' import * as templatesEN from './templates/en' const from = CONFIG.EMAIL_DEFAULT_SENDER -const welcomeImageUrl = new URL(logosWebapp.LOGO_WELCOME_PATH, CONFIG.CLIENT_URI) +const welcomeImageUrl = new URL(CONFIG.LOGO_WELCOME_PATH, CONFIG.CLIENT_URI) const defaultParams = { welcomeImageUrl, APPLICATION_NAME: CONFIG.APPLICATION_NAME, - ORGANIZATION_NAME: metadata.ORGANIZATION_NAME, + ORGANIZATION_NAME: CONFIG.ORGANIZATION_NAME, ORGANIZATION_URL: CONFIG.ORGANIZATION_URL, supportUrl: CONFIG.SUPPORT_URL, } diff --git a/backend/src/middleware/index.ts b/backend/src/middleware/index.ts index 37fd33ef9..080dbd064 100644 --- a/backend/src/middleware/index.ts +++ b/backend/src/middleware/index.ts @@ -1,11 +1,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ -/* eslint-disable @typescript-eslint/restrict-template-expressions */ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ + /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { applyMiddleware, IMiddleware } from 'graphql-middleware' -import CONFIG from '@config/index' +import CONFIG from '@config/config' // eslint-disable-next-line import/no-cycle import brandingMiddlewares from './branding/brandingMiddlewares' diff --git a/backend/src/middleware/notifications/notificationsMiddleware.emails.spec.ts b/backend/src/middleware/notifications/notificationsMiddleware.emails.spec.ts index 79d95e43e..c661d7b2c 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.emails.spec.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.emails.spec.ts @@ -7,11 +7,11 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { createGroupMutation } from '@graphql/queries/createGroupMutation' import { joinGroupMutation } from '@graphql/queries/joinGroupMutation' -import CONFIG from '@src/config' import createServer from '@src/server' CONFIG.CATEGORIES_ACTIVE = false diff --git a/backend/src/middleware/notifications/notificationsMiddleware.followed-users.spec.ts b/backend/src/middleware/notifications/notificationsMiddleware.followed-users.spec.ts index 21d4a14a0..d09e7f514 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.followed-users.spec.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.followed-users.spec.ts @@ -6,10 +6,10 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { createGroupMutation } from '@graphql/queries/createGroupMutation' -import CONFIG from '@src/config' import createServer from '@src/server' CONFIG.CATEGORIES_ACTIVE = false diff --git a/backend/src/middleware/notifications/notificationsMiddleware.mentions-in-groups.spec.ts b/backend/src/middleware/notifications/notificationsMiddleware.mentions-in-groups.spec.ts index 96c7e9d18..fd6a1e441 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.mentions-in-groups.spec.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.mentions-in-groups.spec.ts @@ -7,12 +7,12 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { changeGroupMemberRoleMutation } from '@graphql/queries/changeGroupMemberRoleMutation' import { createGroupMutation } from '@graphql/queries/createGroupMutation' import { joinGroupMutation } from '@graphql/queries/joinGroupMutation' -import CONFIG from '@src/config' import createServer from '@src/server' CONFIG.CATEGORIES_ACTIVE = false diff --git a/backend/src/middleware/notifications/notificationsMiddleware.observing-posts.spec.ts b/backend/src/middleware/notifications/notificationsMiddleware.observing-posts.spec.ts index a0864fe07..0ddac2420 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.observing-posts.spec.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.observing-posts.spec.ts @@ -5,7 +5,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import createServer from '@src/server' diff --git a/backend/src/middleware/notifications/notificationsMiddleware.online-status.spec.ts b/backend/src/middleware/notifications/notificationsMiddleware.online-status.spec.ts index 3a47d376d..6d9f2a294 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.online-status.spec.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.online-status.spec.ts @@ -6,9 +6,9 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' -import CONFIG from '@src/config' import createServer from '@src/server' CONFIG.CATEGORIES_ACTIVE = false diff --git a/backend/src/middleware/notifications/notificationsMiddleware.posts-in-groups.spec.ts b/backend/src/middleware/notifications/notificationsMiddleware.posts-in-groups.spec.ts index 25aef2e2b..2dc4e5d84 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.posts-in-groups.spec.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.posts-in-groups.spec.ts @@ -7,12 +7,12 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getNeode, getDriver } from '@db/neo4j' import { changeGroupMemberRoleMutation } from '@graphql/queries/changeGroupMemberRoleMutation' import { createGroupMutation } from '@graphql/queries/createGroupMutation' import { joinGroupMutation } from '@graphql/queries/joinGroupMutation' -import CONFIG from '@src/config' import createServer from '@src/server' CONFIG.CATEGORIES_ACTIVE = false diff --git a/backend/src/middleware/permissionsMiddleware.spec.ts b/backend/src/middleware/permissionsMiddleware.spec.ts index ca45005fe..dd7212f16 100644 --- a/backend/src/middleware/permissionsMiddleware.spec.ts +++ b/backend/src/middleware/permissionsMiddleware.spec.ts @@ -5,7 +5,7 @@ import { createTestClient } from 'apollo-server-testing' import gql from 'graphql-tag' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import Factory, { cleanDatabase } from '@db/factories' import { getDriver, getNeode } from '@db/neo4j' import createServer from '@src/server' diff --git a/backend/src/middleware/permissionsMiddleware.ts b/backend/src/middleware/permissionsMiddleware.ts index 5725b2d98..6aaeceb73 100644 --- a/backend/src/middleware/permissionsMiddleware.ts +++ b/backend/src/middleware/permissionsMiddleware.ts @@ -6,7 +6,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { rule, shield, deny, allow, or, and } from 'graphql-shield' -import CONFIG from '@config/index' +import CONFIG from '@config/config' import SocialMedia from '@db/models/SocialMedia' import { getNeode } from '@db/neo4j' import { validateInviteCode } from '@graphql/resolvers/transactions/inviteCodes' diff --git a/backend/src/middleware/sentryMiddleware.ts b/backend/src/middleware/sentryMiddleware.ts index 743ec32df..44ff2f2c3 100644 --- a/backend/src/middleware/sentryMiddleware.ts +++ b/backend/src/middleware/sentryMiddleware.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { sentry } from 'graphql-middleware-sentry' -import CONFIG from '@config/index' +import CONFIG from '@config/config' // eslint-disable-next-line import/no-mutable-exports, @typescript-eslint/no-explicit-any let sentryMiddleware: any = (resolve, root, args, context, resolveInfo) => diff --git a/backend/src/server.ts b/backend/src/server.ts index a9fc43a0e..7185e1ebe 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -16,7 +16,7 @@ import { graphqlUploadExpress } from 'graphql-upload' import helmet from 'helmet' import Redis from 'ioredis' -import CONFIG from './config' +import CONFIG from './config/config' import { getNeode, getDriver } from './db/neo4j' import schema from './graphql/schema' import decode from './jwt/decode'