Skip to content

Commit

Permalink
chore: parameterize URLs
Browse files Browse the repository at this point in the history
Signed-off-by: Akiff Manji <[email protected]>
  • Loading branch information
amanji authored and loneil committed Oct 10, 2024
1 parent 19b03fc commit 592789b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion services/tenant-ui/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"server": {
"tractionUrl": "SERVER_TRACTION_URL",
"lokiUrl": "SERVER_LOKI_URL",
"oidc": {
"jwksUri": "SERVER_OIDC_JWKS",
"realm": "SERVER_OIDC_REALM",
Expand All @@ -65,4 +66,4 @@
"innkeeperInbox": "SERVER_SMTP_INNKEEPER_INBOX"
}
}
}
}
3 changes: 2 additions & 1 deletion services/tenant-ui/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"port": "8080",
"staticFiles": "../../frontend/dist",
"tractionUrl": "http://localhost:5100",
"lokiUrl": "ws://localhost:3100",
"oidc": {
"jwksUri": "https://dev.loginproxy.gov.bc.ca/auth/realms/digitaltrust-citz/protocol/openid-connect/certs",
"realm": "digitaltrust-citz",
Expand All @@ -73,4 +74,4 @@
"innkeeperInbox": "lucas.o'[email protected]"
}
}
}
}
7 changes: 5 additions & 2 deletions services/tenant-ui/frontend/src/store/logStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineStore } from 'pinia';
import { Ref, ref } from 'vue';
import { useTokenStore } from './tokenStore';
import { useConfigStore, useTokenStore } from '@/store';

export enum LogStreamState {
OPEN,
Expand All @@ -13,6 +13,7 @@ export enum LogOrder {
}

export const useLogStore = defineStore('log', () => {
const { config } = useConfigStore();
const { token } = useTokenStore();

const logStream: Ref<WebSocket | null> = ref(null);
Expand Down Expand Up @@ -41,7 +42,9 @@ export const useLogStore = defineStore('log', () => {
throw new Error('No token available to start log stream');
}
if (!logStream.value) {
logStream.value = new WebSocket('ws://localhost:8080?token=' + token);
logStream.value = new WebSocket(
`${config.server.lokiUrl}?token=${token}`
);
logStream.value.onopen = () => {
logStreamState.value = LogStreamState.OPEN;
};
Expand Down
2 changes: 1 addition & 1 deletion services/tenant-ui/src/routes/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ router.use(express.json());
// For the secured innkeepr OIDC login request to verify the token and get a token from Traction
router.get(
"/innkeeperLogin",
// @ts-ignore
// @ts-expect-error: secure function is not typed correctly
secure(jwksService),
async (req: any, res: Response, next: NextFunction) => {
try {
Expand Down
7 changes: 3 additions & 4 deletions services/tenant-ui/src/services/log-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import config from "config";
import jwt from "jsonwebtoken";
import WebSocket from "ws";

const WEBSOCKET_URL = "ws://host.docker.internal:3100/loki/api/v1/tail";
// const TRACTION_URL: string = config.get("server.tractionUrl");
const TRACTION_URL = "http://host.docker.internal:8032";
const LOKI_URL: string = config.get("server.lokiUrl");
const TRACTION_URL: string = config.get("server.tractionUrl");

const wss = new WebSocket.Server({ noServer: true });

Expand Down Expand Up @@ -54,7 +53,7 @@ const logError = (err: Error) => {

const handleLokiWebSocket = (tenantId: string, ws: WebSocket) => {
const loki = new WebSocket(
`${WEBSOCKET_URL}?query={container_name="scripts-traction-agent-1"} |= \`${tenantId}\``
`${LOKI_URL}/loki/api/v1/tail?query={container_name="scripts-traction-agent-1"} |= \`${tenantId}\``
);

loki.on("open", () => {
Expand Down

0 comments on commit 592789b

Please sign in to comment.