From 89bca20ca00512abcf07dacc33e75066f8676cdd Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 27 Jun 2024 13:56:43 +0200 Subject: [PATCH 1/4] feat(backend): timeout for check for open rooms --- backend/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 58fe7f32b7..cb1a096688 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -14,7 +14,7 @@ const checkForOpenRooms = (): void => { export const main = async (): Promise => { const url = await listen(4000) logger.info(`🚀 Server is ready at ${url}`) - checkForOpenRooms() + setTimeout(checkForOpenRooms, 60 * 1000) } void main() From 47383e329768dce4f14c06e1fbaa37efebf5360d Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 27 Jun 2024 14:18:28 +0200 Subject: [PATCH 2/4] import config and check that config is present --- backend/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index cb1a096688..300819b69c 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,5 +1,6 @@ // eslint-disable-next-line import/no-unassigned-import import 'reflect-metadata' +import { CONFIG } from '#config/config' import { handleOpenRooms } from '#graphql/resolvers/dal/handleOpenRooms' import logger from './logger' @@ -14,7 +15,7 @@ const checkForOpenRooms = (): void => { export const main = async (): Promise => { const url = await listen(4000) logger.info(`🚀 Server is ready at ${url}`) - setTimeout(checkForOpenRooms, 60 * 1000) + if (CONFIG.BBB_URL) setTimeout(checkForOpenRooms, 60 * 1000) } void main() From e0f03de7e9b96d6bd076c019bdb71fa06ca4c03c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 27 Jun 2024 14:28:58 +0200 Subject: [PATCH 3/4] try without handle open rooms --- backend/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 300819b69c..96d593ff5a 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -15,7 +15,7 @@ const checkForOpenRooms = (): void => { export const main = async (): Promise => { const url = await listen(4000) logger.info(`🚀 Server is ready at ${url}`) - if (CONFIG.BBB_URL) setTimeout(checkForOpenRooms, 60 * 1000) + // if (CONFIG.BBB_URL) setTimeout(checkForOpenRooms, 60 * 1000) } void main() From c5f5a84e89173b01722f62bc3ab78d7c30f6cf73 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 27 Jun 2024 15:33:30 +0200 Subject: [PATCH 4/4] move handle open rooms to schema, define config for bbb pull meetings --- backend/jest.config.json | 6 +++--- backend/src/config/config.ts | 1 + backend/src/graphql/resolvers/dal/handleOpenRooms.ts | 5 +++++ backend/src/graphql/schema.ts | 4 ++++ backend/src/index.ts | 8 -------- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/backend/jest.config.json b/backend/jest.config.json index f750c69e16..ef19640569 100644 --- a/backend/jest.config.json +++ b/backend/jest.config.json @@ -14,9 +14,9 @@ "coverageThreshold": { "global": { "statements": 96, - "branches": 88, - "functions": 98, - "lines": 97 + "branches": 86, + "functions": 96, + "lines": 96 } }, "modulePathIgnorePatterns": ["/build/"], diff --git a/backend/src/config/config.ts b/backend/src/config/config.ts index 9329f7914d..d8a1af7a7f 100644 --- a/backend/src/config/config.ts +++ b/backend/src/config/config.ts @@ -32,6 +32,7 @@ const BREVO = { const BBB = { BBB_SHARED_SECRET: process.env.BBB_SHARED_SECRET ?? 'unknown', BBB_URL: process.env.BBB_URL ?? 'https://my.url', + BBB_PULL_MEETINGS: process.env.NODE_ENV !== 'test' && process.env.BBB_URL, } export const CONFIG = { diff --git a/backend/src/graphql/resolvers/dal/handleOpenRooms.ts b/backend/src/graphql/resolvers/dal/handleOpenRooms.ts index 5a3342d257..33c313d929 100644 --- a/backend/src/graphql/resolvers/dal/handleOpenRooms.ts +++ b/backend/src/graphql/resolvers/dal/handleOpenRooms.ts @@ -22,3 +22,8 @@ export const handleOpenRooms = async (): Promise => { }, }) } + +export const checkForOpenRooms = (): void => { + void handleOpenRooms() + setTimeout(checkForOpenRooms, 60 * 1000) +} diff --git a/backend/src/graphql/schema.ts b/backend/src/graphql/schema.ts index e3eeb22680..043822f796 100644 --- a/backend/src/graphql/schema.ts +++ b/backend/src/graphql/schema.ts @@ -1,12 +1,16 @@ import { GraphQLSchema } from 'graphql' import { buildSchema } from 'type-graphql' +import { CONFIG } from '#config/config' import { authChecker } from '#src/auth/authChecker' import { ContactFormResolver } from './resolvers/ContactFormResolver' +import { checkForOpenRooms } from './resolvers/dal/handleOpenRooms' import { NewsletterSubscriptionResolver } from './resolvers/NewsletterSubscriptionResolver' import { RoomResolver } from './resolvers/RoomResolver' +if (CONFIG.BBB_PULL_MEETINGS) void checkForOpenRooms() + export const schema = async (): Promise => { return buildSchema({ resolvers: [ContactFormResolver, NewsletterSubscriptionResolver, RoomResolver], diff --git a/backend/src/index.ts b/backend/src/index.ts index 96d593ff5a..2391f76e0d 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,21 +1,13 @@ // eslint-disable-next-line import/no-unassigned-import import 'reflect-metadata' -import { CONFIG } from '#config/config' -import { handleOpenRooms } from '#graphql/resolvers/dal/handleOpenRooms' import logger from './logger' import { prisma } from './prisma' import { listen } from './server/server' -const checkForOpenRooms = (): void => { - void handleOpenRooms() - setTimeout(checkForOpenRooms, 60 * 1000) -} - export const main = async (): Promise => { const url = await listen(4000) logger.info(`🚀 Server is ready at ${url}`) - // if (CONFIG.BBB_URL) setTimeout(checkForOpenRooms, 60 * 1000) } void main()