Skip to content
Merged

Dev #65

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b220d6c
chore:adding docker files
Mag-D-Anas Oct 18, 2025
c9ae432
Merge pull request #17 from MarioRaafat/chore/Containerization
Mag-D-Anas Oct 18, 2025
bd76db7
Merge branch 'main' of https://github.com/VIKI-THE-7TH/Backend_mock i…
MarioRaafat Oct 18, 2025
df307ba
feat(all): eslint done
AmiraKhalid04 Oct 21, 2025
5317673
tweet CRUDs + reposts + likes v0
MoBahgat010 Oct 21, 2025
20b933c
fix(style): resolver eslint errors
AmiraKhalid04 Oct 21, 2025
b661a3a
Merge branch 'dev' into feature/tweets
MoBahgat010 Oct 21, 2025
fe47d06
feat(tweets): tweet CRUDs + reposts + likes
MoBahgat010 Oct 22, 2025
abbaea7
Merge branch 'dev' into feature/tweets
MoBahgat010 Oct 22, 2025
796b808
tweet CRUDs + reposts + likes v1
MoBahgat010 Oct 22, 2025
0bde702
fix(tweets): swagger now shows what's returned on successfull requests
shady-2004 Oct 23, 2025
b974eed
feat(tweets:added get tweets per user)
shady-2004 Oct 23, 2025
0f92f8e
feat(tweets):added views & get user tweets
shady-2004 Oct 23, 2025
0a6441d
test(tweets):tweets serive unit tests init
shady-2004 Oct 23, 2025
c67a710
test(tweets):tweets serive unit tests init
shady-2004 Oct 23, 2025
e837e9b
test(tweets):createTweet unit tests
shady-2004 Oct 23, 2025
ce90a2f
test(tweets):updateTweet unit tests
shady-2004 Oct 23, 2025
c18dd80
test(tweets):deleteTweet unit tests
shady-2004 Oct 23, 2025
3a3091f
test(tweets):getTweetById unit tests
shady-2004 Oct 23, 2025
0916051
test(tweets):likeTweet unit tests
shady-2004 Oct 23, 2025
e62753b
test(tweets):unlikeTweet unit tests
shady-2004 Oct 23, 2025
b68e73e
feat(profile): add basic needed endpoints with clear structure
Alyaa242 Oct 25, 2025
9ecd122
fix(auth): fixing some issues in auth flow and adding some APIs for m…
MarioRaafat Oct 26, 2025
e47756b
hotfix(auth): fixing naming matching errors
MarioRaafat Oct 26, 2025
e612a9f
Hashtags + mentions setup + common pagination service
MoBahgat010 Oct 29, 2025
6c341b3
Hashtags + mentions setup + common pagination service
MoBahgat010 Oct 29, 2025
237381b
ci(linting): add husky hooks
Mag-D-Anas Oct 24, 2025
b879fa8
ci(branch naming): change feature to feat
Mag-D-Anas Oct 24, 2025
5bf5b62
ci(git-hooks): turning pre-push to POSIX-safe
Mag-D-Anas Oct 24, 2025
c854b6e
chore(deps): sync package-lock.json for CI compatibility
Mag-D-Anas Oct 24, 2025
656da83
ci(check): changing Prettier flag to auto fix formatting
Mag-D-Anas Oct 24, 2025
92deb83
ci(workflows): add auto-deploy, auto-assign reviewers, and update CI
Mag-D-Anas Oct 30, 2025
e85f7ce
ci(workflows): update reviewers map
Mag-D-Anas Oct 30, 2025
90b7301
chore(packag-lock): fix failing dependencies step
Mag-D-Anas Oct 30, 2025
57e28ce
ci(devOps): CI & Git Hooks Integration
Mag-D-Anas Oct 30, 2025
9570a90
ci(workflow): update location of the dockerfile
Mag-D-Anas Oct 30, 2025
16a799b
Merge branch 'dev' into ci/git-hooks
Mag-D-Anas Oct 30, 2025
7f003b1
ci(workflow): Dockerfile path specification
Mag-D-Anas Oct 30, 2025
f318243
fix(db): run init migration (#29)
AmiraKhalid04 Oct 30, 2025
219c5bd
Feat/db seed (#27)
AmiraKhalid04 Oct 30, 2025
d63849f
fix(db): resolve package json error (#30)
AmiraKhalid04 Oct 30, 2025
aede519
ci(workflows): fix IMG_TAG env in deploy workflow (#34)
Mag-D-Anas Oct 30, 2025
6e96854
ci(workflow): fix version control for docker images (#35)
Mag-D-Anas Oct 30, 2025
d1d455b
ci(app): provide an API for health to check the server in the pipeline
MarioRaafat Oct 30, 2025
7e86978
Ci/adding health check
Mag-D-Anas Oct 30, 2025
84312e3
Merge remote-tracking branch 'origin/dev' into feature/tweets
shady-2004 Oct 30, 2025
4220d3b
feat(tweets): upload image
MoBahgat010 Oct 30, 2025
def040a
feat(tweets): upload images and videos
MoBahgat010 Oct 30, 2025
0ef7f29
feat(tweets): enhance repost system with deletion, timeline sorting, …
shady-2004 Oct 31, 2025
e469c01
feat(tweets): Tweet categorization
MoBahgat010 Oct 31, 2025
ec14697
Merge branch 'feature/tweets' of https://github.com/MarioRaafat/Backe…
shady-2004 Oct 31, 2025
d45bf99
feat(tweets): Tweet finished
MoBahgat010 Oct 31, 2025
640fbfa
feat(tweets): Tweet finished
MoBahgat010 Oct 31, 2025
5b36b13
feat(tweets): Tweet finished
MoBahgat010 Oct 31, 2025
1b2a527
feat(tweets): Tweet finished
MoBahgat010 Oct 31, 2025
b0b3c81
feat(user): add some missing APIs in profile user
Alyaa242 Oct 31, 2025
add9202
hotfix(ci): add missing dependency
Alyaa242 Oct 31, 2025
1769afe
feat(tweets): some changes
MoBahgat010 Oct 31, 2025
9bc8beb
feat(seed): extention for seed
AmiraKhalid04 Oct 31, 2025
936520b
fix(tweets): reposts to original logic & reposts can be viewed for al…
shady-2004 Oct 31, 2025
e900f17
feat(tweets): return following status with user objects in tweets, re…
shady-2004 Oct 31, 2025
cfed02c
feat(tweets): merge feature/tweets branch
shady-2004 Oct 31, 2025
68fe3eb
fix(db): add object to user follows relation instance (#50)
AmiraKhalid04 Oct 31, 2025
c06451e
Merge branch 'dev' into feat/tweets
shady-2004 Oct 31, 2025
7d87ca6
Merge pull request #51 from MarioRaafat/feat/tweets
shady-2004 Oct 31, 2025
b2f95c2
feat(timeline): first version of timeline
AmiraKhalid04 Oct 31, 2025
113180b
feat(test): test env done
MarioRaafat Nov 1, 2025
ed24acd
hotfix(struct): responses struct modification
MarioRaafat Nov 1, 2025
e18ad2f
hotfix(swagger): add server in swagger to provide multi hosts
MarioRaafat Nov 1, 2025
dc799f6
feat(bg jobs): add bull queues for background jobs
MarioRaafat Nov 2, 2025
5088569
fix(timeline): match responses
AmiraKhalid04 Nov 2, 2025
c0d3858
fix(validations): add some required validations and bypass for testing
MarioRaafat Nov 3, 2025
3b195d7
fix(deployment): restart both api and api-local (#61)
Mag-D-Anas Nov 3, 2025
3657d08
Feat/profile v2 (#58)
Alyaa242 Nov 3, 2025
1625877
docs(api): add endpoint status (#54)
AmiraKhalid04 Nov 3, 2025
3bec40a
test(azure-storage): azure storage service unit tests
Alyaa242 Nov 3, 2025
91e4ec4
refactor(tweets): refactoring tweets
MoBahgat010 Nov 3, 2025
ddbd29e
Fix/db-deployemnt-switch (#49)
Alyaa242 Nov 14, 2025
fc044b1
fix(tests) 90% coverage for unit testing (#64)
MarioRaafat Nov 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/reviewer-map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"MarioRaafat": ["AmiraKhalid04", "MoBahgat010"],
"MoBahgat010": ["Alyaa242", "MarioRaafat"],
"shady-2004": ["AmiraKhalid04", "MarioRaafat"],
"Alyaa242": ["shady-2004", "MarioRaafat"],
"AmiraKhalid04": ["MoBahgat010", "MarioRaafat"],
"default": ["MarioRaafat"]
}
54 changes: 54 additions & 0 deletions .github/workflows/auto-assign-reviewers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Auto Assign Reviewers

on:
pull_request:
types: [opened, reopened, ready_for_review]

permissions:
pull-requests: write
contents: read

jobs:
assign_reviewers:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

steps:
- name: checkout repo
uses: actions/checkout@v4

- name: Load reviewers map
id: reviewers
run: |
echo "map=$(cat .github/reviewer-map.json | jq -c .)" >> $GITHUB_OUTPUT

- name: Assign reviewers based on PR author
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const author = context.payload.pull_request.user.login;
const map = JSON.parse(process.env.MAP);

let reviewers = map[author];
if (!reviewers) {
core.info(`⚠️ No reviewers defined for ${author}, Default assignment will be applied`)
reviewers = map["default"];
}

if (!reviewers || reviewers.length === 0) {
core.warning(`❌ No default reviewers found in map. Skipping assignment.`);
return;
}

core.info(`Assigning reviewers: ${reviewers.join(', ')} for PR by ${author}`);

await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
reviewers
});
env:
MAP: ${{ steps.reviewers.outputs.map }}

45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
pull_request:
branches: [ main, dev ]

permissions:
contents: read
pull-requests: write

jobs:
checks:
runs-on: ubuntu-latest
strategy:
fail-fast: true

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

# skip for now, until fixing all lintings, unit tests

# - name: Run ESLint
# run: npm run lint

- name: Check Prettier format
run: npx prettier --write "src/**/*.ts"

# - name: Run unit tests
# run: npm run test:cov

- name: Upload coverage to PR
uses: romeovs/lcov-reporter-action@v0.3.1
with:
lcov-file: ./coverage/lcov.info

131 changes: 131 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Build, Tag & Deploy to Dev

on:
push:
branches:
- dev

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get latest tag from Docker Hub
id: get_tag
run: |
# Fetch tags from Docker Hub
REPO="${{ secrets.DOCKER_USERNAME }}/api-yapper-backend"

echo "🔍 Fetching tags from Docker Hub for $REPO..."

# Get Docker Hub token for authenticated API access
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST \
-d '{"username": "${{ secrets.DOCKER_USERNAME }}", "password": "${{ secrets.DOCKER_PASSWORD }}"}' \
https://hub.docker.com/v2/users/login/ | jq -r .token)

if [ "$TOKEN" = "null" ] || [ -z "$TOKEN" ]; then
echo "❌ Failed to authenticate with Docker Hub"
exit 1
fi

# Get all tags from Docker Hub API
TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" \
"https://hub.docker.com/v2/repositories/$REPO/tags/?page_size=100" | \
jq -r '.results[].name' | \
grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \
sort -V | \
tail -1)

# If no tags found, start with v0.0.0
if [ -z "$TAGS" ]; then
LATEST_TAG="v0.0.0"
echo "⚠️ No version tags found on Docker Hub, starting from v0.0.0"
else
LATEST_TAG="$TAGS"
echo "📦 Latest tag found on Docker Hub: $LATEST_TAG"
fi

echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT

# Parse version components
VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

# Increment patch version
PATCH=$((PATCH + 1))
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"

echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
echo "🚀 New version: $NEW_TAG"

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile

push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/api-yapper-backend:${{ steps.get_tag.outputs.new_tag }}
${{ secrets.DOCKER_USERNAME }}/api-yapper-backend:dev

- name: Confirm image push
run: |
echo "✅ Image pushed: ${{ secrets.DOCKER_USERNAME }}/api-yapper-backend:${{ steps.get_tag.outputs.new_tag }}"
echo "✅ Image tagged: ${{ secrets.DOCKER_USERNAME }}/api-yapper-backend:dev"

- name: SSH into Dev VM and deploy
uses: appleboy/ssh-action@v1.0.0
env:
IMG_TAG: ${{ steps.get_tag.outputs.new_tag }}
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.DEV_SERVER_USER }}
key: ${{ secrets.DEV_SERVER_SSH_KEY }}
envs: IMG_TAG
script: |
set -e
cd ~/yapper # path to your app on VM

echo "🧭 Getting current running image tag..."
CURRENT_TAG=$(IMG_TAG="" docker compose ps -q api | xargs docker inspect -f '{{ index .Config.Labels "com.docker.compose.image" }}' | cut -d':' -f2 || echo "unknown")

echo "🐳 Setting new image tag for deployment..."
echo "Deploying version: $IMG_TAG"

echo "🔄 Pulling new image and restarting app container..."
IMG_TAG=$IMG_TAG docker compose pull api api-local
IMG_TAG=$IMG_TAG docker compose up -d api api-local

echo "⏳ Waiting for health check..."
sleep 10

HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" ${{ secrets.DEV_HEALTHCHECK_URL }})

if [ "$HTTP_CODE" = "200" ]; then
echo "✅ Dev deployment successful for version $IMG_TAG"
else
echo "❌ Health check failed (HTTP $HTTP_CODE)! Rolling back app container..."
if [ "$CURRENT_TAG" != "unknown" ]; then
IMG_TAG=$CURRENT_TAG docker compose up -d api api-local
echo "🔙 Rolled back to $CURRENT_TAG"
fi
exit 1
fi

- name: Deployment summary
if: success()
run: |
echo "🎉 Deployment Complete!"
echo "Version: ${{ steps.get_tag.outputs.new_tag }}"
echo "Branch: dev"
echo "Commit: ${{ github.sha }}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ pids

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

dist
9 changes: 9 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
msg_file=$1
msg=$(cat "$msg_file")

# Conventional commits rule
if ! echo "$msg" | grep -Eq "^(feat|fix|chore|docs|refactor|test|style|perf|ci)\(.+\): .+"; then
echo "❌ Invalid commit message format!"
echo "👉 Example: feat(auth): add login endpoint"
exit 1
fi
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "🔍 Running pre-commit checks..."
npx lint-staged
10 changes: 10 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

branch_name=$(git symbolic-ref --short HEAD)

echo "$branch_name" | grep -Eq '^(feat|fix|chore|hotfix|docs|ci|test)/[a-z0-9._-]+$'
if [ $? -ne 0 ]; then
echo "❌ Invalid branch name: $branch_name"
echo "👉 Branch name must start with feat/, fix/, chore/, docs/, ci/, test/ or hotfix/ (e.g. feat/signup-page)"
exit 1
fi
12 changes: 10 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"trailingComma": "all"
}
"printWidth": 100,
"tabWidth": 4,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf",
"bracketSpacing": true,
"bracketSameLine": false
}
10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

57 changes: 0 additions & 57 deletions Dockerfile.prod

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading