From 69d038f95fed517cb8e2c61f6fb2e81250a84425 Mon Sep 17 00:00:00 2001 From: biersoeckli Date: Sat, 23 Nov 2024 11:05:16 +0000 Subject: [PATCH] fix server.ts and asynclocalstorage --- src/server.ts | 9 ++++++--- src/server/services/param.service.ts | 3 ++- src/server/services/qs.service.ts | 3 +++ src/server/utils/constants.ts | 1 + src/server/utils/fancy-console.utils.ts | 11 +++++++++++ 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/server/utils/fancy-console.utils.ts diff --git a/src/server.ts b/src/server.ts index d7a53b5..c0d5486 100644 --- a/src/server.ts +++ b/src/server.ts @@ -4,11 +4,14 @@ import next from 'next' import socketIoServer from './socket-io.server' import quickStackService from './server/services/qs.service' import { CommandExecutorUtils } from './server/utils/command-executor.utils' -import { ParamService } from './server/services/param.service' import dataAccess from './server/adapter/db.client' +import { FancyConsoleUtils } from './server/utils/fancy-console.utils' +import { Constants } from './server/utils/constants' // Source: https://nextjs.org/docs/app/building-your-application/configuring/custom-server +FancyConsoleUtils.printQuickStack(); + const port = parseInt(process.env.PORT || '3000', 10) const dev = process.env.NODE_ENV !== 'production' @@ -34,10 +37,10 @@ async function initializeNextJs() { console.log('Saving K3S_JOIN_TOKEN to database...'); await dataAccess.client.parameter.upsert({ where: { - name: ParamService.K3S_JOIN_TOKEN + name: Constants.K3S_JOIN_TOKEN }, create: { - name: ParamService.K3S_JOIN_TOKEN, + name: Constants.K3S_JOIN_TOKEN, value: process.env.K3S_JOIN_TOKEN }, update: { diff --git a/src/server/services/param.service.ts b/src/server/services/param.service.ts index 2fb9a2b..d62f6e6 100644 --- a/src/server/services/param.service.ts +++ b/src/server/services/param.service.ts @@ -2,13 +2,14 @@ import { revalidateTag, unstable_cache } from "next/cache"; import dataAccess from "../adapter/db.client"; import { Tags } from "../utils/cache-tag-generator.utils"; import { Parameter, Prisma } from "@prisma/client"; +import { Constants } from "../utils/constants"; export class ParamService { static readonly QS_SERVER_HOSTNAME = 'qsServerHostname'; static readonly DISABLE_NODEPORT_ACCESS = 'disableNodePortAccess'; static readonly LETS_ENCRYPT_MAIL = 'letsEncryptMail'; - static readonly K3S_JOIN_TOKEN = 'k3sJoinToken'; + static readonly K3S_JOIN_TOKEN = Constants.K3S_JOIN_TOKEN; async get(name: string) { return await unstable_cache(async (name: string) => await dataAccess.client.parameter.findFirstOrThrow({ diff --git a/src/server/services/qs.service.ts b/src/server/services/qs.service.ts index 277ff41..07c645d 100644 --- a/src/server/services/qs.service.ts +++ b/src/server/services/qs.service.ts @@ -3,6 +3,7 @@ import { V1Deployment, V1Ingress, V1Service } from "@kubernetes/client-node"; import namespaceService from "./namespace.service"; import { StringUtils } from "../utils/string.utils"; import crypto from "crypto"; +import { FancyConsoleUtils } from "../utils/fancy-console.utils"; class QuickStackService { @@ -22,7 +23,9 @@ class QuickStackService { console.log('QuickStack successfully initialized'); console.log(''); console.log('------------------------------------------------'); + FancyConsoleUtils.printQuickStack(); console.log('You can now access QuickStack UI on the following URL: http://SERVER-IP:30000'); + console.log('') console.log('Hint: Ensure that the port 30000 is open in your firewall.'); console.log('------------------------------------------------'); console.log(''); diff --git a/src/server/utils/constants.ts b/src/server/utils/constants.ts index 8b873f2..9337252 100644 --- a/src/server/utils/constants.ts +++ b/src/server/utils/constants.ts @@ -3,4 +3,5 @@ export class Constants { static readonly QS_ANNOTATION_PROJECT_ID = 'qs-project-id'; static readonly QS_ANNOTATION_DEPLOYMENT_ID = 'qs-deplyoment-id'; static readonly QS_ANNOTATION_GIT_COMMIT = 'qs-git-commit'; + static readonly K3S_JOIN_TOKEN = 'k3sJoinToken';; } \ No newline at end of file diff --git a/src/server/utils/fancy-console.utils.ts b/src/server/utils/fancy-console.utils.ts new file mode 100644 index 0000000..dd6baf5 --- /dev/null +++ b/src/server/utils/fancy-console.utils.ts @@ -0,0 +1,11 @@ +export class FancyConsoleUtils { + public static printQuickStack() { + console.log(''); + console.log(' ___ _ _ ____ _ _ '); + console.log(' / _ \\ _ _(_) ___| | __/ ___|| |_ __ _ ___| | __'); + console.log('| | | | | | | |/ __| |/ /\\___ \\| __/ _` |/ __| |/ /'); + console.log('| |_| | |_| | | (__| < ___) | || (_| | (__| < '); + console.log(' \\__\\_\\\\__,_|_|\\___|_|\\_\\|____/ \\__\\__,_|\\___|_|\\_\\'); + console.log(''); + } +} \ No newline at end of file