@@ -11,22 +11,26 @@ export const use_infra_store = defineStore("infra", {
1111 is_cloud ( ) {
1212 return ! isElectron ( ) && ! process . env . NODE_ENV === "development"
1313 } ,
14- domain_name ( ) {
15- if ( this . is_cloud ) {
14+ domain_name ( state ) {
15+ if ( state . is_cloud ) {
1616 return useRuntimeConfig ( ) . public . API_URL
1717 } else {
1818 return "localhost"
1919 }
2020 } ,
21-
22- api_url ( ) {
21+ lambda_url ( state ) {
2322 const geode_store = use_geode_store ( )
2423 const public_runtime_config = useRuntimeConfig ( ) . public
25- if ( public_runtime_config . NODE_ENV == "test" ) {
26- return ""
27- }
28- var api_url = `${ geode_store . PROTOCOL } ://${ this . domain_name } :${ geode_store . PORT } `
29- return api_url
24+ const url =
25+ geode_store . protocol +
26+ "://" +
27+ state . domain_name +
28+ ":" +
29+ geode_store . port +
30+ public_runtime_config . SITE_BRANCH +
31+ public_runtime_config . PROJECT +
32+ "/createbackend"
33+ return url
3034 } ,
3135 is_running ( ) {
3236 return use_geode_store ( ) . is_running && use_viewer_store ( ) . is_running
@@ -42,21 +46,14 @@ export const use_infra_store = defineStore("infra", {
4246 return
4347 }
4448 this . is_connexion_launched = true
45- if (
46- this . ID === "" ||
47- this . ID === null ||
48- typeof this . ID === "undefined"
49- ) {
49+ if ( [ "" , null ] . includes ( this . ID ) || typeof this . ID === "undefined" ) {
5050 return this . create_backend ( )
5151 } else {
52- const { data, error } = await useFetch ( `${ geode_store . base_url } /` , {
53- method : "POST" ,
54- } )
55- if ( data . value !== null ) {
56- geode_store . is_running = true
52+ try {
53+ await geode_store . do_ping ( )
5754 return geode_store . ping_task ( )
58- } else {
59- await this . create_backend ( )
55+ } catch ( e ) {
56+ return this . create_backend ( )
6057 }
6158 }
6259 } ,
@@ -66,19 +63,15 @@ export const use_infra_store = defineStore("infra", {
6663 const feedback_store = use_feedback_store ( )
6764
6865 if ( isElectron ( ) ) {
69- await window . electronAPI . run_back ( geode_store . PORT )
70- await window . electronAPI . run_viewer ( viewer_store . PORT )
71- // geode_store.$patch({ is_running: true })
72- // viewer_store.$patch({ is_running: true })
66+ const back_port = await window . electronAPI . run_back ( geode_store . port )
67+ geode_store . $patch ( { default_local_port : back_port } )
68+ const viewer_port = await window . electronAPI . run_viewer (
69+ viewer_store . port ,
70+ )
71+ viewer_store . $patch ( { default_local_port : viewer_port } )
7372 return
7473 } else {
75- const public_runtime_config = useRuntimeConfig ( ) . public
76- const url = this . api_url . concat (
77- public_runtime_config . SITE_BRANCH ,
78- public_runtime_config . PROJECT ,
79- "/createbackend" ,
80- )
81- const { data, error } = await useFetch ( url , {
74+ const { data, error } = await useFetch ( this . lambda_url , {
8275 method : "POST" ,
8376 } )
8477 if ( data . value !== null ) {
0 commit comments