update constructing of backend and gradido node server urls

This commit is contained in:
einhornimmond 2025-10-23 09:53:34 +02:00
parent 3501543c07
commit e2cda2c297
4 changed files with 31 additions and 13 deletions

View File

@ -13,12 +13,12 @@ IOTA_HOME_COMMUNITY_SEED=aabbccddeeff00112233445566778899aabbccddeeff00112233445
DLT_CONNECTOR_PORT=6010
# Gradido Node Server URL
NODE_SERVER_URL=http://localhost:8340/api
DLT_NODE_SERVER_PORT=8340
# Gradido Blockchain
GRADIDO_BLOCKCHAIN_CRYPTO_APP_SECRET=21ffbbc616fe
GRADIDO_BLOCKCHAIN_SERVER_CRYPTO_KEY=a51ef8ac7ef1abf162fb7a65261acd7a
# Route to Backend
BACKEND_SERVER_URL=http://localhost:4000
PORT=4000
JWT_SECRET=secret123

View File

@ -36,7 +36,7 @@ export async function checkHomeCommunity(
const { backend, hiero } = appContext.clients
// wait for backend server
await isPortOpenRetry(CONFIG.BACKEND_SERVER_URL)
await isPortOpenRetry(backend.url)
// ask backend for home community
let homeCommunity = await backend.getHomeCommunityDraft()
// on missing topicId, create one
@ -64,8 +64,8 @@ export async function checkHomeCommunity(
}
appContext.cache.setHomeCommunityTopicId(homeCommunity.hieroTopicId)
logger.info(`home community topic: ${homeCommunity.hieroTopicId}`)
logger.info(`gradido node server: ${CONFIG.NODE_SERVER_URL}`)
logger.info(`gradido backend server: ${CONFIG.BACKEND_SERVER_URL}`)
logger.info(`gradido node server: ${appContext.clients.gradidoNode.url}`)
logger.info(`gradido backend server: ${appContext.clients.backend.url}`)
return v.parse(communitySchema, homeCommunity)
}

View File

@ -36,13 +36,21 @@ export class GradidoNodeClient {
private static instance: GradidoNodeClient
client: JsonRpcClient
logger: Logger
urlValue: string
private constructor() {
this.logger = getLogger(`${LOG4JS_BASE_CATEGORY}.client.GradidoNodeClient`)
this.urlValue = `http://localhost:${CONFIG.DLT_NODE_SERVER_PORT}`
this.logger.addContext('url', this.urlValue)
this.client = new JsonRpcClient({
url: CONFIG.NODE_SERVER_URL,
url: this.urlValue,
})
}
public get url(): string {
return this.urlValue
}
public static getInstance(): GradidoNodeClient {
if (!GradidoNodeClient.instance) {
GradidoNodeClient.instance = new GradidoNodeClient()
@ -233,7 +241,7 @@ export class GradidoNodeClient {
// template rpcCall, check first if port is open before executing json rpc 2.0 request
protected async rpcCall<T>(method: string, parameter: any): Promise<JsonRpcEitherResponse<T>> {
this.logger.debug('call %s with %s', method, parameter)
await isPortOpenRetry(CONFIG.NODE_SERVER_URL)
await isPortOpenRetry(this.url)
return this.client.exec<T>(method, parameter)
}

View File

@ -69,12 +69,22 @@ export const configSchema = v.object({
),
500,
),
NODE_SERVER_URL: v.optional(
v.string('The URL of the gradido node server'),
'http://localhost:6010',
DLT_NODE_SERVER_PORT: v.optional(
v.pipe(
v.string('A valid port on which the DLT node server is running'),
v.transform<string, number>((input: string) => Number(input)),
v.minValue(1),
v.maxValue(65535),
),
'8340',
),
BACKEND_SERVER_URL: v.optional(
v.string('The URL of the gradido backend server'),
'http://localhost:6010',
PORT: v.optional(
v.pipe(
v.string('A valid port on which the backend server is running'),
v.transform<string, number>((input: string) => Number(input)),
v.minValue(1),
v.maxValue(65535),
),
'4000',
),
})