Moriz Wahl a3178a91b4
refactor(webapp): store for categories (#8551)
* after authentification, query the categories if active and store them

* get categories from store

* use category store to get categories

* get categories from store

* mock store to have access to categories

* to get rid of the active categories config variable in the frontend, the Category query returns an empty array when categories are not active

* remove CATEGORIES_ACTIVE from .env

* should return string to avoid warnings in console

* replace all env calls for categories active by getter from store

* use categoriesActive getter

* ignore order of returned categories

* mixin to get the category infos from the store, to ensure, that the quey has been called

* fix misspelling

---------

Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>
2025-05-27 15:03:26 +02:00

62 lines
1.9 KiB
JavaScript

// ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env)
import dotenv from 'dotenv'
dotenv.config() // we want to synchronize @nuxt-dotenv and nuxt-env
// Load Package Details for some default values
const pkg = require('../package')
const environment = {
NODE_ENV: process.env.NODE_ENV,
DEBUG: process.env.NODE_ENV !== 'production' || false,
PRODUCTION: process.env.NODE_ENV === 'production' || false,
NUXT_BUILD: process.env.NUXT_BUILD || '.nuxt',
STYLEGUIDE_DEV: process.env.STYLEGUIDE_DEV || false,
}
const server = {
GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000',
BACKEND_TOKEN: process.env.BACKEND_TOKEN || 'NULL',
WEBSOCKETS_URI: process.env.WEBSOCKETS_URI || 'ws://localhost:3000/api/graphql',
}
const sentry = {
SENTRY_DSN_WEBAPP: process.env.SENTRY_DSN_WEBAPP,
COMMIT: process.env.COMMIT,
}
const options = {
VERSION: process.env.VERSION || pkg.version,
DESCRIPTION: process.env.DESCRIPTION || pkg.description,
MAPBOX_TOKEN: process.env.MAPBOX_TOKEN,
PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION === 'true' || false,
INVITE_REGISTRATION: process.env.INVITE_REGISTRATION !== 'false', // default = true
// Cookies
COOKIE_EXPIRE_TIME: process.env.COOKIE_EXPIRE_TIME || 730, // Two years by default
COOKIE_HTTPS_ONLY: process.env.COOKIE_HTTPS_ONLY || process.env.NODE_ENV === 'production', // ensure true in production if not set explicitly
BADGES_ENABLED: process.env.BADGES_ENABLED === 'true' || false,
INVITE_LINK_LIMIT: process.env.INVITE_LINK_LIMIT || 7,
NETWORK_NAME: process.env.NETWORK_NAME || 'Ocelot.social',
}
const language = {
LANGUAGE_DEFAULT: process.env.LANGUAGE_DEFAULT || 'en',
LANGUAGE_FALLBACK: process.env.LANGUAGE_FALLBACK || 'en',
}
const CONFIG = {
...environment,
...server,
...sentry,
...options,
...language,
}
// override process.env with the values here since they contain default values
process.env = {
...process.env,
...CONFIG,
}
export default CONFIG