Skip to content

Commit

Permalink
Merge pull request #4 from JuanmanDev/fix/share-envs
Browse files Browse the repository at this point in the history
feat: return env from endpoint to aling with prod changes
  • Loading branch information
JuanmanDev authored Dec 7, 2024
2 parents 7c753ce + 72a8fbc commit 8628aca
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
ports:
- "3456:3001"
# Update 3456 with the port you want to use
volumes:
- ./.env:/app/.env
environment:
- GHOSTFOLIO_VALIDATE=true
# - GHOSTFOLIO_ACCOUNT_ID="YO"
Expand Down
20 changes: 19 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const isProcessed = ref(false)
const isConnecting = ref(false)
const showServerLogs = ref(false)
const logs = ref("")
let configUpdated;
const GHOSTFOLIO_VALIDATE = ref(!!config.public.GHOSTFOLIO_VALIDATE || false);
const GHOSTFOLIO_IMPORT = ref(!!config.public.GHOSTFOLIO_IMPORT || false);
Expand All @@ -149,6 +149,24 @@ const serverUrl = config.public.serverUrl;
showServerLogs.value = config.public.isDev || false;
try {
fetch("/env").then(async (response) => {
const data = await response.json();
configUpdated = data;
if (data.GHOSTFOLIO_ACCOUNT_ID) GHOSTFOLIO_ACCOUNT_ID.value = data.GHOSTFOLIO_ACCOUNT_ID;
if (data.GHOSTFOLIO_URL) GHOSTFOLIO_URL.value = data.GHOSTFOLIO_URL;
if (data.GHOSTFOLIO_SECRET) GHOSTFOLIO_SECRET.value = data.GHOSTFOLIO_SECRET;
if (data.GHOSTFOLIO_VALIDATE) GHOSTFOLIO_VALIDATE.value = data.GHOSTFOLIO_VALIDATE;
if (data.GHOSTFOLIO_IMPORT) GHOSTFOLIO_IMPORT.value = data.GHOSTFOLIO_IMPORT;
if (data.GHOSTFOLIO_UPDATE_CASH) GHOSTFOLIO_UPDATE_CASH.value = data.GHOSTFOLIO_UPDATE_CASH;
showServerLogs.value = data?.isDev || false;
});
} catch (error) {
console.error('Error fetching config:', error);
}
// Messages shown during processing to provide feedback
const processingMessages = [
'Processing your data...',
Expand Down
14 changes: 14 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ console.log("outputFolder:", outputFolder);
app.use("/" + outputFolder, express.static(outputFolder));


app.get('/env', async (req, res) => {
// Return the environment variables
const envsToSend = {
GHOSTFOLIO_VALIDATE: process.env.GHOSTFOLIO_VALIDATE,
GHOSTFOLIO_IMPORT: process.env.GHOSTFOLIO_IMPORT,
GHOSTFOLIO_UPDATE_CASH: process.env.GHOSTFOLIO_UPDATE_CASH,
GHOSTFOLIO_ACCOUNT_ID: process.env.GHOSTFOLIO_ACCOUNT_ID,
GHOSTFOLIO_URL: process.env.GHOSTFOLIO_URL,
GHOSTFOLIO_SECRET: process.env.GHOSTFOLIO_SECRET,
serverUrl: process.env.NODE_ENV === 'production' ? '/' : 'http://localhost:3001/',
isDev: process.env.NODE_ENV !== 'production',
}
res.send(envsToSend);
})


app.post('/upload', upload.single('file'), async (req, res) => {
Expand Down

0 comments on commit 8628aca

Please sign in to comment.