From 526d2ce835113c86c8a4eaf296bdf2477bd5461b Mon Sep 17 00:00:00 2001 From: wajeht <58354193+wajeht@users.noreply.github.com> Date: Sat, 27 Apr 2024 22:14:23 -0500 Subject: [PATCH 1/4] style: Fix typos and update ports to 80 --- .env.example | 2 +- .vscode/settings.json | 2 ++ Dockerfile.dev | 4 ++-- Dockerfile.prod | 4 ++-- docker-compose.dev.yml | 4 ++-- src/api/federations/federations.routes.ts | 2 +- src/api/health-check/health-check.services.ts | 2 +- src/api/meets/meets.services.ts | 10 +++++----- src/app.ts | 2 +- 9 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.env.example b/.env.example index 159ef57..df9fb02 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ # app -PORT=8082 +PORT=80 ENV="development" DOMAIN="https://close-powerlifting.jaw.dev" MONGODB_URI="mongodb://username:password@mongodb:27017/close-powerlifting?authSource=admin" # docker diff --git a/.vscode/settings.json b/.vscode/settings.json index 314ded9..9641256 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,10 +14,12 @@ "multistream", "openpowerlifting", "pino", + "powerlifing", "powerlifting", "resave", "tailwindcss", "unhashed", + "uspa", "wajeht" ], "dotenv.enableAutocloaking": false diff --git a/Dockerfile.dev b/Dockerfile.dev index ff8ba53..a1a9a5d 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -13,8 +13,8 @@ COPY ./ ./ RUN npm install -EXPOSE 8082 +EXPOSE 80 CMD ["npm", "run", "dev"] -HEALTHCHECK CMD curl -f http://localhost:8082/api/health-check || exit 1 +HEALTHCHECK CMD curl -f http://localhost:80/api/health-check || exit 1 diff --git a/Dockerfile.prod b/Dockerfile.prod index b774651..4ec1d89 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -18,8 +18,8 @@ RUN npm install RUN npm run build # RUN npm run minify:html -EXPOSE 8082 +EXPOSE 80 CMD ["npm", "run", "start"] -HEALTHCHECK CMD curl -f http://localhost:8082/api/health-check || exit 1 +HEALTHCHECK CMD curl -f http://localhost:80/api/health-check || exit 1 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 4f55695..96ce882 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -7,7 +7,7 @@ services: context: ./ dockerfile: ./Dockerfile.dev ports: - - '8082:8082' + - '80:80' volumes: - ./:/usr/src/app - /usr/src/app/node_modules @@ -31,7 +31,7 @@ services: mongodb: container_name: mongodb - image: mongo:latest + image: mongo:4 restart: unless-stopped environment: MONGO_INITDB_ROOT_USERNAME: username diff --git a/src/api/federations/federations.routes.ts b/src/api/federations/federations.routes.ts index 0bdb0de..9b511dc 100644 --- a/src/api/federations/federations.routes.ts +++ b/src/api/federations/federations.routes.ts @@ -34,7 +34,7 @@ federations.get( * @tags federations * @summary get list of federations of a federation by year * @param {string} federation.path.required - the federation - application/x-www-form-urlencoded - * @param {number} year.query - the yeare - application/x-www-form-urlencoded + * @param {number} year.query - the year - application/x-www-form-urlencoded * @param {boolean} cache.query - the cache - application/x-www-form-urlencoded * @security BearerAuth */ diff --git a/src/api/health-check/health-check.services.ts b/src/api/health-check/health-check.services.ts index 88f6a97..59960d5 100644 --- a/src/api/health-check/health-check.services.ts +++ b/src/api/health-check/health-check.services.ts @@ -47,7 +47,7 @@ export async function getAPIStatus({ X_API_KEY, url }: { X_API_KEY: string; url: return data; }; - const cacheKey = `close-powerlifting-gloabl-status-call-cache`; + const cacheKey = `close-powerlifting-global-status-call-cache`; // @ts-ignore let data = JSON.parse(await redis.get(cacheKey)); diff --git a/src/api/meets/meets.services.ts b/src/api/meets/meets.services.ts index 6bdad84..971d609 100644 --- a/src/api/meets/meets.services.ts +++ b/src/api/meets/meets.services.ts @@ -35,15 +35,15 @@ export async function getMeet({ meet, cache = true }: getMeetParamType & getMeet } // @ts-ignore - let cachedMeeet = JSON.parse(await redis.get(`meet-${meet}`)); + let cachedMeet = JSON.parse(await redis.get(`meet-${meet}`)); - if (!cachedMeeet) { - cachedMeeet = await fetchMeet({ meet }); + if (!cachedMeet) { + cachedMeet = await fetchMeet({ meet }); // @ts-ignore - await redis.set(`meet-${meet}`, JSON.stringify(cachedMeeet)); + await redis.set(`meet-${meet}`, JSON.stringify(cachedMeet)); } - return cachedMeeet; + return cachedMeet; } catch (error) { if (error instanceof AxiosError) { if (error.response?.status === StatusCodes.NOT_FOUND) { diff --git a/src/app.ts b/src/app.ts index ad039e6..5905293 100644 --- a/src/app.ts +++ b/src/app.ts @@ -65,7 +65,7 @@ if (ENV === ENV_ENUMS.PRODUCTION) { app.use( express.static(path.resolve(path.join(process.cwd(), 'public')), { - // 30 days in miliseconds + // 30 days in milliseconds maxAge: 30 * 24 * 60 * 60 * 1000, }), ); From a07cd2cab2cfd8b77f4bcdc461bab2c00ce65cbe Mon Sep 17 00:00:00 2001 From: wajeht <58354193+wajeht@users.noreply.github.com> Date: Sat, 27 Apr 2024 22:17:05 -0500 Subject: [PATCH 2/4] ci: Update deployment workflow for production deployment --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f01e526..5f7d993 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: pull_request: env: - PORT: 8080 + PORT: 80 ENV: 'testing' DOMAIN: 'https://close-powerlifting.jaw.dev' PASSWORD_SALT: 5 @@ -105,9 +105,12 @@ jobs: deploy: needs: [format, test, lint] - name: Deploy to caprover + name: Deploy to production runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/main' + environment: + name: production + url: https://close-powerlifting.jaw.dev/ steps: - name: Check out repository @@ -134,7 +137,7 @@ jobs: push: true tags: ${{ env.IMAGE_URL }} - - name: Deploy Image to CapRrover + - name: Deploy Image to Production uses: caprover/deploy-from-github@v1.1.2 with: server: '${{ secrets.CAPROVER_SERVER }}' From 8ef98d6183c0ebf696b185f836cc4304b89af64f Mon Sep 17 00:00:00 2001 From: wajeht <58354193+wajeht@users.noreply.github.com> Date: Sat, 27 Apr 2024 22:18:03 -0500 Subject: [PATCH 3/4] style: Remove unnecessary div and align attributes --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 34a7ed4..e59d84f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ -#
an intuitive api for open-powerlifting database
+an intuitive api for open-powerlifting database # 📚 Technologies From 25f71b59991da68bde47a26d3b76419738abf9f1 Mon Sep 17 00:00:00 2001 From: wajeht <58354193+wajeht@users.noreply.github.com> Date: Sat, 27 Apr 2024 22:19:50 -0500 Subject: [PATCH 4/4] docs: Add getting started guide with commands --- docs/getting-started.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/getting-started.md b/docs/getting-started.md index e69de29..c8f0236 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -0,0 +1,30 @@ +# Getting Started +Clone the repository + +```bash +$ git clone https://github.com/wajeht/close-powerlifting.git +``` + +Copy `.env.example` to `.env` + +```bash +$ cp .env.example .env +``` + +Install dependencies + +```bash +$ npm install +``` + +Run development server + +```bash +$ npm run dev +``` + +Test the application + +```bash +$ npm run test +```