@@ -3,7 +3,10 @@ import { ref } from 'vue'
33import AWS from 'aws-sdk'
44
55export const useAppStore = defineStore ( 'app' , ( ) => {
6- const endpoint = ref ( localStorage . getItem ( 'localstack-endpoint' ) || 'http://localhost:4566' )
6+ const endpoint = ref ( import . meta. env . VITE_LOCALSTACK_ENDPOINT || 'http://localhost:4566' )
7+ const region = ref ( import . meta. env . VITE_AWS_DEFAULT_REGION || 'us-east-1' )
8+ const accessKeyId = ref ( import . meta. env . VITE_AWS_ACCESS_KEY_ID || 'test' )
9+ const secretAccessKey = ref ( import . meta. env . VITE_AWS_SECRET_ACCESS_KEY || 'test' )
710 const connectionStatus = ref ( 'disconnected' )
811 const snackbar = ref ( {
912 show : false ,
@@ -14,9 +17,9 @@ export const useAppStore = defineStore('app', () => {
1417
1518 // AWS SDK Configuration
1619 const awsConfig = {
17- region : 'us-east-1' ,
18- accessKeyId : 'test' ,
19- secretAccessKey : 'test' ,
20+ region : region . value ,
21+ accessKeyId : accessKeyId . value ,
22+ secretAccessKey : secretAccessKey . value ,
2023 endpoint : endpoint . value ,
2124 s3ForcePathStyle : true ,
2225 sslEnabled : false
@@ -53,12 +56,16 @@ export const useAppStore = defineStore('app', () => {
5356 const checkConnection = async ( ) => {
5457 try {
5558 connectionStatus . value = 'connecting'
56-
59+
5760 // Try to list S3 buckets as a health check
5861 if ( ! s3 . value ) initializeServices ( )
59-
60- await s3 . value . listBuckets ( ) . promise ( )
61- connectionStatus . value = 'connected'
62+
63+ if ( s3 . value ) {
64+ await s3 . value . listBuckets ( ) . promise ( )
65+ connectionStatus . value = 'connected'
66+ } else {
67+ connectionStatus . value = 'disconnected'
68+ }
6269 } catch ( error ) {
6370 connectionStatus . value = 'disconnected'
6471 console . error ( 'Connection failed:' , error )
@@ -74,7 +81,7 @@ export const useAppStore = defineStore('app', () => {
7481 }
7582 }
7683
77- // Initialize services on store creation
84+ // Initialize services on store creation
7885 initializeServices ( )
7986
8087 return {
0 commit comments