From ba4872fe5bc68642e449c25c418f2c7f8c514104 Mon Sep 17 00:00:00 2001 From: adjoly Date: Tue, 2 Sep 2025 13:12:03 +0200 Subject: [PATCH 1/6] =?UTF-8?q?=E3=80=8C=F0=9F=93=9D=E3=80=8D=20doc(.env):?= =?UTF-8?q?=20full?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.env.example b/.env.example index 34d30e2..8ecbc62 100644 --- a/.env.example +++ b/.env.example @@ -15,3 +15,12 @@ GOOGLE_CALLBACK_URL=https://localhost:8443/api/v1 GOOGLE_CLIENT_SECRET=susAF GOOGLE_CLIENT_ID=Really +AVAX_PRIVATE_KEY= +AVAX_RPC_URL= +AVAX_CONTRACT_ADDR= + +SMTP_SMARTHOST= +SMTP_FROM= +SMTP_AUTH_USERNAME= +SMTP_AUTH_PASSWORD= +EMAIL_TO= From 89e98bef2a85e5c61f5248b9c704c5e19db8fc54 Mon Sep 17 00:00:00 2001 From: adjoly Date: Wed, 10 Sep 2025 23:10:20 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=E3=80=8C=E2=9C=A8=E3=80=8D=20feat:=20added?= =?UTF-8?q?=20container=20for=20scoreStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/api-base/Dockerfile | 2 +- docker/api-base/compose.yml | 21 +++++++++++++++++++-- docker/volumes.yml | 4 ++++ src/start.js | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docker/api-base/Dockerfile b/docker/api-base/Dockerfile index 142d056..e291122 100644 --- a/docker/api-base/Dockerfile +++ b/docker/api-base/Dockerfile @@ -6,7 +6,7 @@ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml /app/ # install all the dependency RUN npm install -g pnpm RUN cd /app \ - && pnpm install --prod + && pnpm install --prod --frozen-lockfile FROM node:lts-alpine AS base diff --git a/docker/api-base/compose.yml b/docker/api-base/compose.yml index 9ce5386..76b987e 100644 --- a/docker/api-base/compose.yml +++ b/docker/api-base/compose.yml @@ -10,7 +10,6 @@ services: networks: - front - back - - prom-exporter environment: - TZ=Europe/Paris - API_TARGET=user @@ -28,7 +27,6 @@ services: networks: - front - back - - prom-exporter environment: - TZ=Europe/Paris - GOOGLE_CALLBACK_URL=${GOOGLE_CALLBACK_URL} @@ -38,3 +36,22 @@ services: - LOG_FILE_PATH=/var/log/log.log - JWT_SECRET=${JWT_SECRET} restart: unless-stopped + scorestore-api: + container_name: transcendence-api-scoreStore + build: + dockerfile: docker/api-base/Dockerfile + context: ../../ + volumes: + - db-scoreStore:/db + - log-scoreStore:/var/log + networks: + - front + - back + environment: + - TZ=Europe/Paris + - API_TARGET=scoreStore + - LOG_FILE_PATH=/var/log/log.log + - AVAX_PRIVATE_KEY=${AVAX_PRIVATE_KEY} + - AVAX_RPC_URL=${AVAX_RPC_URL} + - AVAX_CONTRACT_ADDR=${AVAX_CONTRACT_ADDR} + restart: unless-stopped diff --git a/docker/volumes.yml b/docker/volumes.yml index f05e822..188877f 100644 --- a/docker/volumes.yml +++ b/docker/volumes.yml @@ -5,9 +5,13 @@ volumes: name: transcendence-api-auth-db db-user: name: transcendence-api-user-db + db-scoreStore: + name: transcendence-api-scoreStore log-auth: name: transcendence-api-auth-log log-user: name: transcendence-api-user-log log-nginx: name: transcendence-front-log + log-scoreStore: + name: transcendence-scoreStore-log diff --git a/src/start.js b/src/start.js index 42f2cbc..6175791 100644 --- a/src/start.js +++ b/src/start.js @@ -58,7 +58,7 @@ async function start() { servers.push(user); } - if (target === 'scoreScore' || target === 'all') { + if (target === 'scoreStore' || target === 'all') { const score = Fastify({ logger: loggerOption('scoreStore') }); score.register(scoreApi); const port = target === 'all' ? 3002 : 3000; From a8713a02d114e368019efd2910de9265fae5fe02 Mon Sep 17 00:00:00 2001 From: adjoly Date: Wed, 10 Sep 2025 23:28:11 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=E3=80=8C=F0=9F=93=9D=E3=80=8D=20doc(scoreS?= =?UTF-8?q?tore):=20added=20documentation=20on=20the=20behavior=20(that=20?= =?UTF-8?q?are=20pretty=20sus)=20of=20the=20scoreStore=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/scoreStore/README.md | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 doc/scoreStore/README.md diff --git a/doc/scoreStore/README.md b/doc/scoreStore/README.md new file mode 100644 index 0000000..2208f89 --- /dev/null +++ b/doc/scoreStore/README.md @@ -0,0 +1,56 @@ +# scoreStore + +Available endpoints: +- GET '/:id' +- POST '/' + +Common return: +- 500 with response +```json +{ + "error": "Internal server error" +} +``` + +## GET `/:id` + +Used to get an score from the blockchain (the id is the one returned when a score is added) + +Inputs: +:id : the id of the score + +Returns: +- 200 +```json +{ + "score": { + "p1": "", + "p2": "", + "p1Score": "", + "p2Score": "" + }, + "tx": "" +} +``` + +## POST `/` + +Used to add a new score (note that those can't be removed after added) + +Inputs (this one need to be the same as the following otherwise you will have an error 500): +```json +{ + "p1": "", + "p2": "", + "p1Score": "", + "p2Score": "" +} +``` + +Returns: +- 200 +```json +{ + "id": "" +} +``` From cdad9d8a8e53d6742cea483c69d62b6ccd4b68df Mon Sep 17 00:00:00 2001 From: adjoly Date: Wed, 10 Sep 2025 23:29:11 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20fix?= =?UTF-8?q?ed=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/scoreStore/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/scoreStore/README.md b/doc/scoreStore/README.md index 2208f89..0276a44 100644 --- a/doc/scoreStore/README.md +++ b/doc/scoreStore/README.md @@ -1,8 +1,8 @@ # scoreStore Available endpoints: -- GET '/:id' -- POST '/' +- GET `/:id` +- POST `/` Common return: - 500 with response From 9d7ce7f2df4fe1b1c764e9ef39bcf20129d8289b Mon Sep 17 00:00:00 2001 From: adjoly Date: Wed, 10 Sep 2025 23:31:08 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=E3=80=8C=E2=9C=A8=E3=80=8D=20feat(logstash?= =?UTF-8?q?/scoreStore):=20added=20scoreStore=20logs=20to=20logstash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/ELK/logstash/compose.yml | 1 + docker/ELK/logstash/pipeline/logstash.conf | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docker/ELK/logstash/compose.yml b/docker/ELK/logstash/compose.yml index be01856..9bc1dd4 100644 --- a/docker/ELK/logstash/compose.yml +++ b/docker/ELK/logstash/compose.yml @@ -8,6 +8,7 @@ services: - log-user:/var/log/user-api - log-auth:/var/log/auth-api - log-nginx:/var/log/nginx + - log-scoreStore:/var/log/scoreStore environment: - LOG_LEVEL=info networks: diff --git a/docker/ELK/logstash/pipeline/logstash.conf b/docker/ELK/logstash/pipeline/logstash.conf index 1a53ae5..aedf06c 100644 --- a/docker/ELK/logstash/pipeline/logstash.conf +++ b/docker/ELK/logstash/pipeline/logstash.conf @@ -19,6 +19,11 @@ input { start_position => "beginning" tags => [ "nginx", "front", "error" ] } + file { + path => "/var/log/scoreStore/log.log" + start_position => "beginning" + tags => [ "api", "scoreStore" ] + } } output { From 4900db1e989c3dfb142668645071269774c7b0ba Mon Sep 17 00:00:00 2001 From: adjoly Date: Sat, 13 Sep 2025 13:15:27 +0200 Subject: [PATCH 6/6] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix(start)?= =?UTF-8?q?:=20fixed=20port=20for=20scoreStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/start.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/start.js b/src/start.js index 6175791..df7bc0e 100644 --- a/src/start.js +++ b/src/start.js @@ -61,7 +61,7 @@ async function start() { if (target === 'scoreStore' || target === 'all') { const score = Fastify({ logger: loggerOption('scoreStore') }); score.register(scoreApi); - const port = target === 'all' ? 3002 : 3000; + const port = target === 'all' ? 3003 : 3000; const host = target === 'all' ? '127.0.0.1' : '0.0.0.0'; await score.listen({ port, host }); console.log(`ScoreStore API listening on http://${host}:${port}`);