clean config

This commit is contained in:
Ulf Gebhardt 2025-05-03 02:56:09 +02:00
parent 68edc47f65
commit 1b48103d29
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
53 changed files with 233 additions and 248 deletions

View File

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

2
backend/.gitignore vendored
View File

@ -3,7 +3,7 @@ node_modules/
.vscode
.idea
yarn-error.log
build/*
build/
coverage.lcov
.nyc_output/
public/uploads/*

View File

@ -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<string, string> } | 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,
}

View File

@ -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',
}

View File

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

View File

@ -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',
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,2 +0,0 @@
// this file is duplicated in `backend/src/config/registration.ts` and `webapp/constants/registration.js`
export default {}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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!')
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 }) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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