From 355729ddcf46ec8e96ea41f75dc2dc33261d4b4d Mon Sep 17 00:00:00 2001 From: xavs Date: Mon, 18 May 2026 09:36:15 +0200 Subject: [PATCH] Add configuration files and update API URL in MeteocatService - Created .dockerignore, .editorconfig, .gitignore, .prettierrc, .vscode configurations (extensions.json, launch.json, mcp.json, tasks.json). - Updated nginx.conf to include API proxy settings. - Changed apiUrl in MeteocatService to use relative path. --- .dockerignore | 51 ++++++++++++++++++++++++++++ .editorconfig | 17 ++++++++++ .gitignore | 44 ++++++++++++++++++++++++ .prettierrc | 12 +++++++ .vscode/extensions.json | 4 +++ .vscode/launch.json | 20 +++++++++++ .vscode/mcp.json | 9 +++++ .vscode/tasks.json | 42 +++++++++++++++++++++++ nginx.conf | 16 +++++++++ src/app/services/meteocat.service.ts | 2 +- 10 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .prettierrc create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/mcp.json create mode 100644 .vscode/tasks.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8466f8f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,51 @@ +# Dependencies +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Build output +dist/ +.angular/ + +# IDE +.idea/ +.vscode/ +*.iml +.project +.classpath +.settings/ + +# OS +.DS_Store +Thumbs.db + +# Misc +*.log +*.tmp +*.bak +*.swp +*~ + +# Git +.git/ +.gitignore +.gitattributes + +# Docker +Dockerfile +.dockerignore + +# Testing +coverage/ +.nyc_output/ + +# Documentation +README.md +docs/ +Docs/ + +# Environment files (se deben pasar como variables de entorno) +.env +.env.local +.env.*.local diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f166060 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# Editor configuration, see https://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.ts] +quote_type = single +ij_typescript_use_double_quotes = false + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..854acd5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. + +# Compiled output +/dist +/tmp +/out-tsc +/bazel-out + +# Node +/node_modules +npm-debug.log +yarn-error.log + +# IDEs and editors +.idea/ +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# Visual Studio Code +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/mcp.json +.history/* + +# Miscellaneous +/.angular/cache +.sass-cache/ +/connect.lock +/coverage +/libpeerconnection.log +testem.log +/typings +__screenshots__/ + +# System files +.DS_Store +Thumbs.db diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..d6c16d7 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 100, + "singleQuote": true, + "overrides": [ + { + "files": "*.html", + "options": { + "parser": "angular" + } + } + ] +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..77b3745 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 + "recommendations": ["angular.ng-template"] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a87a760 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "ng serve", + "type": "chrome", + "request": "launch", + "preLaunchTask": "npm: start", + "url": "http://0.0.0.0:4200/" + }, + { + "name": "ng test", + "type": "chrome", + "request": "launch", + "preLaunchTask": "npm: test", + "url": "http://localhost:9876/debug.html" + } + ] +} diff --git a/.vscode/mcp.json b/.vscode/mcp.json new file mode 100644 index 0000000..956af8c --- /dev/null +++ b/.vscode/mcp.json @@ -0,0 +1,9 @@ +{ + // For more information, visit: https://angular.dev/ai/mcp + "servers": { + "angular-cli": { + "command": "npx", + "args": ["-y", "@angular/cli", "mcp"] + } + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..244306f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "start", + "isBackground": true, + "problemMatcher": { + "owner": "typescript", + "pattern": "$tsc", + "background": { + "activeOnStart": true, + "beginsPattern": { + "regexp": "Changes detected" + }, + "endsPattern": { + "regexp": "bundle generation (complete|failed)" + } + } + } + }, + { + "type": "npm", + "script": "test", + "isBackground": true, + "problemMatcher": { + "owner": "typescript", + "pattern": "$tsc", + "background": { + "activeOnStart": true, + "beginsPattern": { + "regexp": "Changes detected" + }, + "endsPattern": { + "regexp": "bundle generation (complete|failed)" + } + } + } + } + ] +} diff --git a/nginx.conf b/nginx.conf index 4c0af3c..4a75b15 100644 --- a/nginx.conf +++ b/nginx.conf @@ -34,6 +34,22 @@ http { try_files $uri $uri/ /index.html; } + # Proxy al backend (API) + location /api/ { + proxy_pass http://meteocat-backend:8080/api/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_cache_bypass $http_upgrade; + proxy_connect_timeout 60s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + } + # Cache para assets estáticos location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; diff --git a/src/app/services/meteocat.service.ts b/src/app/services/meteocat.service.ts index e8c3de5..692726c 100644 --- a/src/app/services/meteocat.service.ts +++ b/src/app/services/meteocat.service.ts @@ -11,7 +11,7 @@ import { EstacioMesCercanaResponse } from '../models/estacio-mes-cercana.model'; providedIn: 'root' }) export class MeteocatService { - private readonly apiUrl = 'http://localhost:8080/api/v1'; + private readonly apiUrl = '/api/v1'; constructor(private http: HttpClient) { }