From 45404157b3bc6b7980ca9018d9a08392336c6613 Mon Sep 17 00:00:00 2001 From: BinarySandia04 Date: Tue, 17 Mar 2026 19:48:05 +0100 Subject: [PATCH] Backend integrated? --- backend/src/index.js | 5 +- frontend/.env.production | 1 + frontend/.gitignore | 2 +- frontend/Dockerfile | 3 +- frontend/app/assets/css/colors.scss | 6 +- frontend/app/composables/api.js | 27 + frontend/app/pages/index.vue | 15 + frontend/i18n/locales/ca.json | 3 + frontend/i18n/locales/en.json | 3 + frontend/i18n/locales/es.json | 3 + frontend/nuxt.config.ts | 15 +- frontend/package.json | 1 + frontend/pnpm-lock.yaml | 1581 ++++++++++++++++++++++++++- frontend/tsconfig.json | 5 +- nginx.conf | 12 + 15 files changed, 1624 insertions(+), 58 deletions(-) create mode 100644 frontend/.env.production create mode 100644 frontend/app/composables/api.js diff --git a/backend/src/index.js b/backend/src/index.js index 68d0c26..81a603d 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -7,8 +7,9 @@ const connectDB = require("./db"); // connect database connectDB(); -app.get("/", (req, res) => { - res.send("Hello from Proxmox container!"); +app.get("/api/test", (req, res) => { + console.log("Hey"); + res.json({"message": "Hello from backend!"}); }); app.listen(5000, () => { diff --git a/frontend/.env.production b/frontend/.env.production new file mode 100644 index 0000000..497ef1c --- /dev/null +++ b/frontend/.env.production @@ -0,0 +1 @@ +API_BASE_URL=https://aranroig.com/api diff --git a/frontend/.gitignore b/frontend/.gitignore index 4a7f73a..d7d7e54 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -21,4 +21,4 @@ logs # Local env files .env .env.* -!.env.example +!.env.production diff --git a/frontend/Dockerfile b/frontend/Dockerfile index a176bdc..5377d3e 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -13,8 +13,7 @@ RUN npm install COPY . . # Build the Nuxt app -RUN npm run build - +RUN npm run build --dotenv .env.production # ---------- Production Stage ---------- FROM node:20-alpine diff --git a/frontend/app/assets/css/colors.scss b/frontend/app/assets/css/colors.scss index 6a35bb6..f0330ab 100644 --- a/frontend/app/assets/css/colors.scss +++ b/frontend/app/assets/css/colors.scss @@ -1,3 +1,5 @@ +@use "sass:map"; + $themes: ( dark: ( background: #141414, @@ -24,9 +26,9 @@ $themes: ( } :root { - @include theme-vars(map-get($themes, dark)); + @include theme-vars(map.get($themes, dark)); } [data-theme="light"] { - @include theme-vars(map-get($themes, light)); + @include theme-vars(map.get($themes, light)); } \ No newline at end of file diff --git a/frontend/app/composables/api.js b/frontend/app/composables/api.js new file mode 100644 index 0000000..9da341b --- /dev/null +++ b/frontend/app/composables/api.js @@ -0,0 +1,27 @@ +// composables/useApi.js +import { ref } from 'vue' + +export default function useApi() { + const config = useRuntimeConfig() + const baseUrl = config.public.apiBaseUrl + + // Generic GET request + const get = async (endpoint) => { + const res = await fetch(`${baseUrl}${endpoint}`) + if (!res.ok) throw new Error(`API GET ${endpoint} failed`) + return res.json() + } + + // Generic POST request + const post = async (endpoint, payload) => { + const res = await fetch(`${baseUrl}${endpoint}`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(payload) + }) + if (!res.ok) throw new Error(`API POST ${endpoint} failed`) + return res.json() + } + + return { get, post } +} \ No newline at end of file diff --git a/frontend/app/pages/index.vue b/frontend/app/pages/index.vue index 56d8347..cbd88f7 100644 --- a/frontend/app/pages/index.vue +++ b/frontend/app/pages/index.vue @@ -1,3 +1,18 @@ + +