File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { json } from '@sveltejs/kit' ;
2
+
3
+ export function GET ( ) {
4
+ return json ( { status : 'ok' } ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ import { json } from '@sveltejs/kit' ;
2
+
3
+ const GRAPHQL_API_URL = process . env . VITE_GRAPHQL_ENDPOINT || 'http://localhost:3000/graphql' ;
4
+
5
+ async function checkGraphQLAPI ( ) {
6
+ try {
7
+ const response = await fetch ( GRAPHQL_API_URL , {
8
+ method : 'POST'
9
+ } ) ;
10
+
11
+ if ( response . status === 401 ) {
12
+ return true ;
13
+ }
14
+
15
+ return response . ok ;
16
+ } catch ( error ) {
17
+ console . log ( error ) ;
18
+ return false ;
19
+ }
20
+ }
21
+
22
+ let isAppReady = false ;
23
+
24
+ async function ready ( ) {
25
+ isAppReady = await checkGraphQLAPI ( ) ;
26
+ setTimeout ( ready , 1000 ) ;
27
+ }
28
+
29
+ ready ( ) ;
30
+
31
+ export async function GET ( ) {
32
+ return json (
33
+ { status : isAppReady ? 'ready' : 'waiting-for-api' } ,
34
+ { status : isAppReady ? 200 : 503 }
35
+ ) ;
36
+ }
You can’t perform that action at this time.
0 commit comments