Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoRedondoo committed May 10, 2024
2 parents 21982e7 + 9d6782f commit bf9b440
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 7 deletions.
85 changes: 85 additions & 0 deletions front/src/routes/integrations/basketProxyVEG/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<svelte:head>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
</svelte:head>

<script>
import { onMount } from 'svelte';
import axios from 'axios';
import { dev } from '$app/environment';
import { Container, ListGroup, ListGroupItem } from '@sveltestrap/sveltestrap';
let players = [];
onMount(async () => {
try {
let API = 'https://sos2324-14.appspot.com';
if (dev) API = 'http://localhost:10002';
const response = await axios.get(`${API}/proxyBasketVEG`);
players = response.data.results;
if (players.length > 0) {
const chartData = {
labels: players.map(player => player.entity.name),
series: players.map(player => player.score)
};
const options = {
chart: {
type: 'pie',
height: 400
},
labels: chartData.labels,
series: chartData.series,
responsive: [{
breakpoint: 480,
options: {
chart: {
width: 200
},
legend: {
position: 'bottom'
}
}
}]
};
new ApexCharts(document.querySelector('#chart'), options).render();
}
} catch (error) {
console.error('Error fetching data:', error);
}
});
</script>

<Container>
<h1>Uso Textual/Widget API Externa 3 (Basket API): con proxy</h1>
<h5>Detalles de jugadores con nombre "Kevin"</h5>
{#if players.length > 0}
<ListGroup>
{#each players as player}
<ListGroupItem>
<p>Nombre: {player.entity.name}</p>
<p>Equipo: {player.entity.team.name}</p>
<p>Posición: {player.entity.position}</p>
<p>Puntuación: {player.score}</p>
</ListGroupItem>
{/each}
</ListGroup>
{:else}
<p>No hay datos disponibles.</p>
{/if}

<div id="chart"></div>
</Container>

<style>
#chart {
margin-top: 20px;
width: 100%;
height: 400px;
}
</style>



2 changes: 1 addition & 1 deletion front/src/routes/integrations/f1DataVEG/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</svelte:head>

<Container>
<h1>Integración API Externa 2(F1 Live Motorsport Data)</h1>
<h1>Uso Widget API Externa 2(F1 Live Motorsport Data): sin proxy</h1>
<h5>Clasificación mundial de pilotos por temporada (2024)</h5>
<div id="chart"></div>

Expand Down
2 changes: 1 addition & 1 deletion front/src/routes/integrations/youtubeDataVEG/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</script>

<Container>
<h1>Uso API Externa 1 (YouTube Data)</h1>
<h1>Uso Textual API Externa 1 (YouTube Data): sin proxy</h1>
<h5>Detalles de un canal</h5>
{#if channelDetails}
<ListGroup>
Expand Down
30 changes: 25 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@ const PORT = (process.env.PORT || 10002);

app.use(cors());

//Proxy VEG
app.use("/proxyVEG", function(req,res){
var url = "https://sos2324-14.appspot.com/api/v1/youtube-trends";
console.log("piped: " + req.url);
req.pipe(request(url)).pipe(res);

//Proxy BasketVEG
app.use("/proxyBasketVEG", function(req, res) {
var url = "https://basketapi1.p.rapidapi.com/api/basketball/search/kevin"; // URL de la API de baloncesto
console.log("Proxying to: " + url);

// Realizar la solicitud a la API de baloncesto
request({
url: url,
qs: req.query, // Pasar los parámetros de la solicitud
headers: {
'X-RapidAPI-Key': 'c4dcccf12bmshb28d319bf18afe1p17ebd3jsn3d5ff8dfec68',
'X-RapidAPI-Host': 'basketapi1.p.rapidapi.com'
}
}).pipe(res); // Enviar la respuesta de la API de baloncesto de vuelta al cliente
});


//Proxy NRM
app.use("/proxyNRM", function(req,res){
var url = "https://sos2324-14.appspot.com/api/v2/ufc-events-data";
Expand All @@ -53,6 +64,15 @@ app.listen(PORT,()=>{
console.log(`Server listening on port ${PORT}.`);
});



//Middleware para el proxy de la API VEG (para hacer pruebas)
app.use("/proxyVEG", function(req, res) {
var url = "https://sos2324-14.appspot.com/api/v1/youtube-trends" + req.url;
console.log("Proxying to: " + url);
req.pipe(request(url)).pipe(res);
});

// Nicolas Redondo Moreno
// API v2
api_NRM(app, dbUfc);
Expand Down

0 comments on commit bf9b440

Please sign in to comment.