Skip to content

Commit

Permalink
Merge pull request #70 from wajeht/feature/maintenance
Browse files Browse the repository at this point in the history
feature/maintenance
  • Loading branch information
wajeht authored Apr 28, 2024
2 parents 4d83182 + 25f71b5 commit 950bed1
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
PORT: 8080
PORT: 80
ENV: 'testing'
DOMAIN: 'https://close-powerlifting.jaw.dev'
PASSWORD_SALT: 5
Expand Down Expand Up @@ -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
Expand All @@ -134,7 +137,7 @@ jobs:
push: true
tags: ${{ env.IMAGE_URL }}

- name: Deploy Image to CapRrover
- name: Deploy Image to Production
uses: caprover/[email protected]
with:
server: '${{ secrets.CAPROVER_SERVER }}'
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
"multistream",
"openpowerlifting",
"pino",
"powerlifing",
"powerlifting",
"resave",
"tailwindcss",
"unhashed",
"uspa",
"wajeht"
],
"dotenv.enableAutocloaking": false
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# <div align="center"> 🏋🏻 Close Powerlifting </div>
# 🏋🏻 Close Powerlifting

<div align="center">
[![Node.js CI](https://github.com/wajeht/close-powerlifting/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/wajeht/close-powerlifting/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/ISC)
[![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/allkindsofgains/gains)

[![Node.js CI](https://github.com/wajeht/close-powerlifting/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/wajeht/close-powerlifting/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/ISC) [![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/allkindsofgains/gains)

</div>

<p align="center"> an intuitive api for open-powerlifting database </p>
an intuitive api for open-powerlifting database

# 📚 Technologies

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: ./
dockerfile: ./Dockerfile.dev
ports:
- '8082:8082'
- '80:80'
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
Expand All @@ -31,7 +31,7 @@ services:

mongodb:
container_name: mongodb
image: mongo:latest
image: mongo:4
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: username
Expand Down
30 changes: 30 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 1 addition & 1 deletion src/api/federations/federations.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/api/health-check/health-check.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 5 additions & 5 deletions src/api/meets/meets.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
);
Expand Down

0 comments on commit 950bed1

Please sign in to comment.