Skip to content

Commit 4802863

Browse files
committed
feat: add dotenv support for environment variables and update API_URI usage
1 parent 73a5860 commit 4802863

File tree

10 files changed

+40
-5
lines changed

10 files changed

+40
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
API_URI=
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile

01-contenedores/lemoncode-challenge/dotnet-stack/frontend/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

01-contenedores/lemoncode-challenge/dotnet-stack/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"license": "ISC",
1515
"dependencies": {
1616
"@fullcalendar/web-component": "^6.1.19",
17+
"dotenv": "^17.2.3",
1718
"ejs": "^3.1.6",
1819
"express": "^4.17.1",
1920
"node-fetch": "^3.0.0"

01-contenedores/lemoncode-challenge/dotnet-stack/frontend/server.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//Módulos
2-
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
2+
const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
33
const express = require('express'),
44
app = express();
5+
require('dotenv').config();
56

6-
const LOCAL = 'http://localhost:5000/api/classes';
7+
const LOCAL = process.env.API_URI || 'http://localhost:5000/api/classes';
78
const PORT = 3000;
89
const APP_URL = `http://localhost:${PORT}`;
910

@@ -21,10 +22,10 @@ app.get('/', async (req, res) => {
2122
//Recuperar clases de la API
2223
const apiUrl = process.env.API_URI || LOCAL;
2324
console.log(`🔄 Conectando a la API: ${apiUrl}`);
24-
25+
2526
const response = await fetch(apiUrl);
2627
const classes = await response.json();
27-
28+
2829
console.log(`✅ ${classes.length} clases cargadas correctamente`);
2930
res.render('index', { classes });
3031
} catch (error) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
API_URI=
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile

01-contenedores/lemoncode-challenge/node-stack/frontend/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

01-contenedores/lemoncode-challenge/node-stack/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"author": "Lemoncode",
2222
"license": "MIT",
2323
"dependencies": {
24+
"dotenv": "^17.2.3",
2425
"ejs": "^3.1.10",
2526
"express": "^4.19.2",
2627
"node-fetch": "^3.3.2"

01-contenedores/lemoncode-challenge/node-stack/frontend/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//Módulos
22
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
3-
const express = require('express'),
3+
const
4+
express = require('express'),
45
app = express();
6+
require('dotenv').config();
57

68
const LOCAL = 'http://localhost:5000/api/classes';
79
const PORT = 3000;

0 commit comments

Comments
 (0)