From e44da4d6a3298bdd0247cf7d0f76ed21bbb17989 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Thu, 11 Apr 2024 00:40:38 +0200 Subject: [PATCH] rework review comments --- backend/src/apis/gms/GmsClient.ts | 19 +++++++------------ backend/src/util/utilities.ts | 4 ++++ deployment/bare_metal/.env.dist | 2 ++ frontend/public/img/{svg => }/loupe.png | Bin frontend/src/components/Menu/Sidebar.vue | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) rename frontend/public/img/{svg => }/loupe.png (100%) diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index 6708c5fc2..e5ce08bbf 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -9,10 +9,11 @@ import { LogError } from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' import { GmsUser } from './model/GmsUser' +import { ensureUrlEndsWithSlash } from '@/util/utilities' /* export async function communityList(): Promise { - const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/') + const baseUrl = ensureUrlEndsWithSlash(CONFIG.GMS_URL) const service = 'community/list?page=1&perPage=20' const config = { headers: { @@ -44,7 +45,7 @@ export async function communityList(): Promise { - const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/') + const baseUrl = ensureUrlEndsWithSlash(CONFIG.GMS_URL) const service = 'community-user/list?page=1&perPage=20' const config = { headers: { @@ -80,7 +81,7 @@ export async function userList(): Promise { } export async function userByUuid(uuid: string): Promise { - const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/') + const baseUrl = ensureUrlEndsWithSlash(CONFIG.GMS_URL) const service = 'community-user/list?page=1&perPage=20' const config = { headers: { @@ -118,9 +119,7 @@ export async function userByUuid(uuid: string): Promise { if (CONFIG.GMS_ACTIVE) { - const baseUrl = CONFIG.GMS_API_URL.endsWith('/') - ? CONFIG.GMS_API_URL - : CONFIG.GMS_API_URL.concat('/') + const baseUrl = ensureUrlEndsWithSlash(CONFIG.GMS_API_URL) const service = 'community-user' const config = { headers: { @@ -154,9 +153,7 @@ export async function createGmsUser(apiKey: string, user: GmsUser): Promise { if (CONFIG.GMS_ACTIVE) { - const baseUrl = CONFIG.GMS_API_URL.endsWith('/') - ? CONFIG.GMS_API_URL - : CONFIG.GMS_API_URL.concat('/') + const baseUrl = ensureUrlEndsWithSlash(CONFIG.GMS_API_URL) const service = 'community-user' const config = { headers: { @@ -193,9 +190,7 @@ export async function verifyAuthToken( communityUuid: string, token: string, ): Promise { - const baseUrl = CONFIG.GMS_API_URL.endsWith('/') - ? CONFIG.GMS_API_URL - : CONFIG.GMS_API_URL.concat('/') + const baseUrl = ensureUrlEndsWithSlash(CONFIG.GMS_API_URL) const service = 'verify-auth-token?token='.concat(token).concat('&uuid=').concat(communityUuid) const config = { headers: { diff --git a/backend/src/util/utilities.ts b/backend/src/util/utilities.ts index c3895cb9e..bc2c2198a 100644 --- a/backend/src/util/utilities.ts +++ b/backend/src/util/utilities.ts @@ -29,3 +29,7 @@ export function resetInterface>(obj: T): T { } return obj } + +export const ensureUrlEndsWithSlash = (url: string): string => { + return url.endsWith('/') ? url : url.concat('/') +} diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index d3f6c356b..64ba8f66b 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -125,3 +125,5 @@ GMS_ACTIVE=false #GMS_API_URL=http://54.176.169.179:3071 GMS_API_URL=http://localhost:4044/ GMS_DASHBOARD_URL=http://localhost:8080/ +GMS_WEBHOOK_SECRET=secret +GMS_CREATE_USER_THROW_ERRORS=false \ No newline at end of file diff --git a/frontend/public/img/svg/loupe.png b/frontend/public/img/loupe.png similarity index 100% rename from frontend/public/img/svg/loupe.png rename to frontend/public/img/loupe.png diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index 2421c82c2..227275786 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -33,7 +33,7 @@ {{ $t('navigation.info') }} - + {{ $t('navigation.usersearch') }}