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= diff --git a/doc/scoreStore/README.md b/doc/scoreStore/README.md new file mode 100644 index 0000000..0276a44 --- /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": "" +} +``` 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 { 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..df7bc0e 100644 --- a/src/start.js +++ b/src/start.js @@ -58,10 +58,10 @@ 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; + 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}`);