fix(api-gateway): make revisions and workspace server urls optional

This commit is contained in:
Karol Sójko
2022-11-25 11:28:02 +01:00
parent 86f6057207
commit 8907879a19
2 changed files with 13 additions and 2 deletions

View File

@@ -54,11 +54,11 @@ export class ContainerConfigLoader {
// env vars
container.bind(TYPES.SYNCING_SERVER_JS_URL).toConstantValue(env.get('SYNCING_SERVER_JS_URL'))
container.bind(TYPES.AUTH_SERVER_URL).toConstantValue(env.get('AUTH_SERVER_URL'))
container.bind(TYPES.REVISIONS_SERVER_URL).toConstantValue(env.get('REVISIONS_SERVER_URL'))
container.bind(TYPES.REVISIONS_SERVER_URL).toConstantValue(env.get('REVISIONS_SERVER_URL', true))
container.bind(TYPES.PAYMENTS_SERVER_URL).toConstantValue(env.get('PAYMENTS_SERVER_URL', true))
container.bind(TYPES.FILES_SERVER_URL).toConstantValue(env.get('FILES_SERVER_URL', true))
container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
container.bind(TYPES.WORKSPACE_SERVER_URL).toConstantValue(env.get('WORKSPACE_SERVER_URL'))
container.bind(TYPES.WORKSPACE_SERVER_URL).toConstantValue(env.get('WORKSPACE_SERVER_URL', true))
container.bind(TYPES.WEB_SOCKET_SERVER_URL).toConstantValue(env.get('WEB_SOCKET_SERVER_URL', true))
container
.bind(TYPES.HTTP_CALL_TIMEOUT)

View File

@@ -39,6 +39,11 @@ export class HttpService implements HttpServiceInterface {
endpoint: string,
payload?: Record<string, unknown> | string,
): Promise<void> {
if (!this.revisionsServerUrl) {
response.status(400).send({ message: 'Revisions Server not configured' })
return
}
await this.callServer(this.revisionsServerUrl, request, response, endpoint, payload)
}
@@ -66,6 +71,12 @@ export class HttpService implements HttpServiceInterface {
endpoint: string,
payload?: Record<string, unknown> | string,
): Promise<void> {
if (!this.workspaceServerUrl) {
response.status(400).send({ message: 'Workspace Server not configured' })
return
}
await this.callServer(this.workspaceServerUrl, request, response, endpoint, payload)
}