Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sos2324 jul #12

Merged
merged 9 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ dist
gc-sa-key.json

front/node_modules
frontend/node_modules
/test-results/
/playwright-report/
/blob-report/
Expand Down
2 changes: 1 addition & 1 deletion API/api-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function apiUfc(app, dbUfc) {
}
}
})
});
})

// POST Nuevo evento
app.post(API_BASE + "/ufc-events-data", (req, res) => {
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Usar una imagen base oficial de Node.js
FROM node:18

# Crear un directorio de trabajo
WORKDIR /app

# Copiar package.json y package-lock.json
COPY package*.json ./

# Instalar las dependencias del proyecto
RUN npm install

# Copiar el resto del código de la aplicación
COPY . .

# Exponer el puerto en el que tu aplicación escuchará
EXPOSE 3000

# Comando para ejecutar tu aplicación
CMD ["npm", "start"]
2 changes: 1 addition & 1 deletion front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"request": "^2.88.2",
"sveltestrap": "^5.11.3"
}
}
}
18 changes: 18 additions & 0 deletions front/src/routes/about/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
import { dev } from "$app/environment";
import { Container } from '@sveltestrap/sveltestrap';

let mode = "production"

if(dev)
mode = "development"
</script>

<Container>
Estas en modo {mode}
<br>
<h1>Vídeos</h1>
<ul>
<li><a href="https://youtu.be/IDtIBTFnutc">Nicolás Redondo Moreno </a></li>
</ul>
</Container>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@

async function fetchTop10UFCEvents() {
try {
let API = 'http://localhost:10002/api/v1';
let API = 'https://sos2324-jul-nrm-428011.ew.r.appspot.com/api/v1';

const response = await fetch(`${API}/ufc-events-data`);
if (response.ok) {
const data = await response.json();
Expand Down
3 changes: 0 additions & 3 deletions front/src/routes/ufc-events-data/graph/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@
}





async function fillPieChart(dt) {
console.log('Entro en pie charts');
const durationMap = new Map();
Expand Down
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import express from "express";
import bodyParser from "body-parser";
import dataStore from "nedb";
import {handler} from "./front/build/handler.js";

import cors from 'cors';

//API
import {apiUfc} from './API/api-v1.js';
let dataUfc = new dataStore();

let app = express();
const PORT = (process.env.PORT || 10002);

//Proxy NRM
app.use("/ufc-events-data", function(req,res){
var url = "https://sos2324-jul-nrm-428011.ew.r.appspot.com/api/v1/ufc-events-data";
console.log("piped: " + req.url);
req.pipe(request(url)).pipe(res);
});
const PORT = (process.env.PORT || 3000);

app.use(cors({
"origin": "*",
"methods" : "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"optionsSuccessStatus":204
}));

app.use(bodyParser.json());

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"name": "sos2324-jul-nrm",
"version": "1.0.0",
Expand Down
18 changes: 11 additions & 7 deletions tests/e2e/home.spec.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
const { test, expect } = require('@playwright/test');

test('has title', async ({ page }) => {
await page.goto('http://localhost:10002');
await page.goto('https://sos2324-jul-nrm-428011.ew.r.appspot.com');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/APIs nicredmor/);
});

test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/');
test('loads data list on button click', async ({ page }) => {
await page.goto('https://sos2324-jul-nrm-428011.ew.r.appspot.com/ufc-events-data');

// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();
// Click the "Insertar datos" button
await page.locator('text=Insertar datos').click();

// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
// Wait for the list container to be visible
await page.waitForSelector('.event-box'); // Replace with actual CSS selector for event container

// Verify the list contains elements
const items = await page.$$('.event-box'); // Replace with actual CSS selector for event items
expect(items.length).toBeGreaterThan(0);
});
6 changes: 3 additions & 3 deletions tests/integration/enviroments/local-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"values": [
{
"key": "SERVER",
"value": "http://localhost:10002",
"value": "http://localhost:3000",
"type": "default",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2024-06-28T12:26:22.774Z",
"_postman_exported_using": "Postman/11.2.23-240627-1207"
"_postman_exported_at": "2024-07-04T20:18:30.106Z",
"_postman_exported_using": "Postman/11.2.32-240627-0756"
}
Loading