File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import DashBaseView from "../pages/dashboard/DashBaseView.vue";
1010import HomeView from " ../pages/HomeView.vue" ;
1111import VerifyView from " ../pages/verify/VerifyView.vue" ;
1212import LoginView from " ../pages/LoginView.vue" ;
13+ import {Health } from " ../stores/health.js" ;
1314
1415const routes = {
1516 ' ^/$' : HomeView,
@@ -31,6 +32,7 @@ window.addEventListener('hashchange', () => {
3132})
3233
3334const currentView = computed (() => {
35+ Health .loadHealth ().then (() => console .log (" Backend is Healthy" ))
3436 for (const path in routes) {
3537 if (new RegExp (path).test (currentPath .value )) {
3638 return routes[path]
Original file line number Diff line number Diff line change 1+ import axios from "axios" ;
2+ import { User } from "./user.js" ;
3+
4+ const VITE_KB_API_URL = import . meta. env . VITE_KB_API_URL
5+
6+ let user = User . loadCache ( ) ;
7+
8+ export class Health {
9+ status
10+
11+ constructor ( status ) {
12+ this . status = status
13+ }
14+
15+ toJson ( ) {
16+ return {
17+ 'status' : this . status
18+ }
19+ }
20+
21+ static fromJson ( json ) {
22+ let health = new Health ( )
23+ health . status = json [ 'status' ]
24+ return health
25+ }
26+
27+ static async loadHealth ( ) {
28+ // Used to warm up backend
29+ let r = await axios . get ( `${ VITE_KB_API_URL } /health` , { } ) ;
30+
31+ return Health . fromJson ( r . data )
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments