From 4aac6c043e52ed992464ba6e8cc3af4172963c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Frnka?= Date: Sun, 21 Apr 2024 21:11:11 +0200 Subject: [PATCH 1/2] SMA-101: added env variables for different environments --- .../resources/application-prod.properties | 22 +++++++++++++++++++ frontend/sportsmatch-app/.env | 1 + frontend/sportsmatch-app/.env.production | 1 + frontend/sportsmatch-app/src/App.tsx | 1 + frontend/sportsmatch-app/src/vite-env.d.ts | 8 +++++++ 5 files changed, 33 insertions(+) create mode 100644 backend/sportsmatch/src/main/resources/application-prod.properties create mode 100644 frontend/sportsmatch-app/.env create mode 100644 frontend/sportsmatch-app/.env.production diff --git a/backend/sportsmatch/src/main/resources/application-prod.properties b/backend/sportsmatch/src/main/resources/application-prod.properties new file mode 100644 index 00000000..fe3e4b6c --- /dev/null +++ b/backend/sportsmatch/src/main/resources/application-prod.properties @@ -0,0 +1,22 @@ +spring.datasource.url=jdbc:postgresql://quirky-bugbear-7185.7tc.aws-eu-central-1.cockroachlabs.cloud:26257/sportsmingle?sslmode=verify-full +spring.datasource.username=matt +spring.datasource.password={ask for it} +spring.jpa.hibernate.ddl-auto=update +spring.datasource.driver-class-name=org.postgresql.Driver +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true +spring.jpa.properties.hibernate.generate_statistics=true +spring.h2.console.enabled=true +spring.mvc.hiddenmethod.filter.enabled=true + +spring.jpa.defer-datasource-initialization=true +spring.sql.init.mode=always + +app.sportsmingle.initialization.database-init=true +app.sportsmingle.jwt.secret=j20qeDeHCI6vGstychuoW2mknL8kmmQW66UCTDSz4jNfSNdd1eUpqEsUfVkOq9tO +app.sportsmingle.frontend.url=sportsmingle.app + +app.sportsmingle.num-game-threshold=5,15,25 +app.sportsmingle.k-factors=25.0,15.0,10.0 +app.sportsmingle.k-factor-default=5.0 \ No newline at end of file diff --git a/frontend/sportsmatch-app/.env b/frontend/sportsmatch-app/.env new file mode 100644 index 00000000..ed5ee609 --- /dev/null +++ b/frontend/sportsmatch-app/.env @@ -0,0 +1 @@ +VITE_BACKEND_URL=http://localhost:8080 \ No newline at end of file diff --git a/frontend/sportsmatch-app/.env.production b/frontend/sportsmatch-app/.env.production new file mode 100644 index 00000000..408a3f1b --- /dev/null +++ b/frontend/sportsmatch-app/.env.production @@ -0,0 +1 @@ +VITE_BACKEND_URL= \ No newline at end of file diff --git a/frontend/sportsmatch-app/src/App.tsx b/frontend/sportsmatch-app/src/App.tsx index 8a040528..5b8d2a61 100644 --- a/frontend/sportsmatch-app/src/App.tsx +++ b/frontend/sportsmatch-app/src/App.tsx @@ -14,6 +14,7 @@ import HostEvent from './pages/HostEvent' import { useEffect } from 'react' function App() { + OpenAPI.BASE = import.meta.env.VITE_BACKEND_URL OpenAPI.TOKEN = localStorage.getItem('token')! useEffect(() => { diff --git a/frontend/sportsmatch-app/src/vite-env.d.ts b/frontend/sportsmatch-app/src/vite-env.d.ts index 11f02fe2..401a59ba 100644 --- a/frontend/sportsmatch-app/src/vite-env.d.ts +++ b/frontend/sportsmatch-app/src/vite-env.d.ts @@ -1 +1,9 @@ /// + +interface ImportMetaEnv { + readonly VITE_BACKEND_URL: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} From 9cdbb6353f36b01e7b2db6e1cc6b94cb39392108 Mon Sep 17 00:00:00 2001 From: MatejFrnka Date: Sun, 21 Apr 2024 22:10:49 +0200 Subject: [PATCH 2/2] Update application-prod.properties --- .../src/main/resources/application-prod.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/sportsmatch/src/main/resources/application-prod.properties b/backend/sportsmatch/src/main/resources/application-prod.properties index fe3e4b6c..eb146548 100644 --- a/backend/sportsmatch/src/main/resources/application-prod.properties +++ b/backend/sportsmatch/src/main/resources/application-prod.properties @@ -14,9 +14,9 @@ spring.jpa.defer-datasource-initialization=true spring.sql.init.mode=always app.sportsmingle.initialization.database-init=true -app.sportsmingle.jwt.secret=j20qeDeHCI6vGstychuoW2mknL8kmmQW66UCTDSz4jNfSNdd1eUpqEsUfVkOq9tO +app.sportsmingle.jwt.secret={ask for it} app.sportsmingle.frontend.url=sportsmingle.app app.sportsmingle.num-game-threshold=5,15,25 app.sportsmingle.k-factors=25.0,15.0,10.0 -app.sportsmingle.k-factor-default=5.0 \ No newline at end of file +app.sportsmingle.k-factor-default=5.0