Skip to content

Commit a63177c

Browse files
authored
Merge pull request #42 from Visitha2001/05-ci-cd
formated
2 parents 4839c0f + dced0a0 commit a63177c

26 files changed

Lines changed: 428 additions & 218 deletions

.github/workflows/docker-build-and-push.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ env:
1212
jobs:
1313
build-and-push:
1414
runs-on: ubuntu-latest
15-
15+
1616
steps:
1717
- name: Checkout code
1818
uses: actions/checkout@v4
19-
19+
2020
- name: Set up Docker Buildx
2121
uses: docker/setup-buildx-action@v3
22-
22+
2323
- name: Log in to Docker Hub
2424
uses: docker/login-action@v3
2525
with:
2626
registry: ${{ env.REGISTRY }}
2727
username: ${{ secrets.DOCKER_USERNAME }}
2828
password: ${{ secrets.DOCKER_PASSWORD }}
29-
29+
3030
- name: Extract metadata
3131
id: meta
3232
uses: docker/metadata-action@v5
@@ -41,7 +41,7 @@ jobs:
4141
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
4242
org.opencontainers.image.description=Acquisitions backend application
4343
org.opencontainers.image.vendor=DevOps HandsOn
44-
44+
4545
- name: Build and push Docker image
4646
id: build
4747
uses: docker/build-push-action@v5
@@ -53,7 +53,7 @@ jobs:
5353
labels: ${{ steps.meta.outputs.labels }}
5454
cache-from: type=gha
5555
cache-to: type=gha,mode=max
56-
56+
5757
- name: Generate summary
5858
run: |
5959
echo "🐳 **Docker Image Published Successfully!**" >> $GITHUB_STEP_SUMMARY
@@ -74,4 +74,4 @@ jobs:
7474
echo "**Pull Command:**" >> $GITHUB_STEP_SUMMARY
7575
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
7676
echo "docker pull ${{ env.REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
77-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
77+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

.github/workflows/lint-and-format.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,40 @@ on:
99
jobs:
1010
lint-and-format:
1111
runs-on: ubuntu-latest
12-
12+
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
16-
16+
1717
- name: Setup Node.js
1818
uses: actions/setup-node@v4
1919
with:
2020
node-version: '20.x'
2121
cache: 'npm'
22-
22+
2323
- name: Install dependencies
2424
run: npm ci
25-
25+
2626
- name: Run ESLint
2727
run: |
2828
echo "Running ESLint..."
2929
if ! npm run lint; then
3030
echo "::error title=ESLint Issues Found::ESLint found issues. Run 'npm run lint:fix' to automatically fix some issues."
3131
exit 1
3232
fi
33-
33+
3434
- name: Run Prettier Check
3535
run: |
3636
echo "Checking code formatting with Prettier..."
3737
if ! npm run format:check; then
3838
echo "::error title=Code Formatting Issues::Code formatting issues found. Run 'npm run format' to fix formatting."
3939
exit 1
4040
fi
41-
41+
4242
- name: Success Summary
4343
if: success()
4444
run: |
4545
echo "✅ All linting and formatting checks passed!" >> $GITHUB_STEP_SUMMARY
4646
echo "" >> $GITHUB_STEP_SUMMARY
4747
echo "- ESLint: No issues found" >> $GITHUB_STEP_SUMMARY
48-
echo "- Prettier: Code formatting is correct" >> $GITHUB_STEP_SUMMARY
48+
echo "- Prettier: Code formatting is correct" >> $GITHUB_STEP_SUMMARY

.github/workflows/tests.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12-
12+
1313
env:
1414
NODE_ENV: test
1515
NODE_OPTIONS: --experimental-vm-modules
1616
DATABASE_URL: postgresql://test:test@localhost:5432/acquisitions_test
17-
17+
1818
steps:
1919
- name: Checkout code
2020
uses: actions/checkout@v4
21-
21+
2222
- name: Setup Node.js
2323
uses: actions/setup-node@v4
2424
with:
2525
node-version: '20.x'
2626
cache: 'npm'
27-
27+
2828
- name: Install dependencies
2929
run: npm ci
30-
30+
3131
- name: Run tests
3232
id: run-tests
3333
run: |
@@ -41,34 +41,34 @@ jobs:
4141
echo "::error title=Test Failures::Some tests failed. Check the logs above for details."
4242
exit 1
4343
fi
44-
44+
4545
- name: Upload coverage reports
4646
uses: actions/upload-artifact@v4
4747
if: always()
4848
with:
4949
name: coverage-reports
5050
path: coverage/
5151
retention-days: 30
52-
52+
5353
- name: Generate test summary
5454
if: always()
5555
run: |
5656
echo "" >> $GITHUB_STEP_SUMMARY
5757
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
5858
echo "" >> $GITHUB_STEP_SUMMARY
59-
59+
6060
if [ -f "coverage/lcov.info" ]; then
6161
echo "📊 **Coverage Report Available**" >> $GITHUB_STEP_SUMMARY
6262
echo "Coverage reports have been uploaded as artifacts." >> $GITHUB_STEP_SUMMARY
6363
fi
64-
64+
6565
echo "" >> $GITHUB_STEP_SUMMARY
6666
echo "**Environment Variables:**" >> $GITHUB_STEP_SUMMARY
6767
echo "- NODE_ENV: $NODE_ENV" >> $GITHUB_STEP_SUMMARY
6868
echo "- NODE_OPTIONS: $NODE_OPTIONS" >> $GITHUB_STEP_SUMMARY
6969
echo "- DATABASE_URL: [configured]" >> $GITHUB_STEP_SUMMARY
70-
70+
7171
if [ "${{ steps.run-tests.outputs.test_status }}" = "failed" ]; then
7272
echo "" >> $GITHUB_STEP_SUMMARY
7373
echo "⚠️ **Action Required:** Fix the failing tests before merging." >> $GITHUB_STEP_SUMMARY
74-
fi
74+
fi

WARP.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This file provides guidance to WARP (warp.dev) when working with code in this re
55
## Development Commands
66

77
### Basic Development
8+
89
```bash
910
# Start development server with file watching
1011
npm run dev
@@ -17,6 +18,7 @@ npm run prod:docker
1718
```
1819

1920
### Code Quality
21+
2022
```bash
2123
# Lint code
2224
npm run lint
@@ -32,6 +34,7 @@ npm run format:check
3234
```
3335

3436
### Database Operations
37+
3538
```bash
3639
# Generate new migration files from schema changes
3740
npm run db:generate
@@ -44,6 +47,7 @@ npm run db:studio
4447
```
4548

4649
### Docker Development
50+
4751
```bash
4852
# View development container logs
4953
docker logs acquisitions-app-dev
@@ -61,6 +65,7 @@ docker-compose -f docker-compose.prod.yml down -v
6165
```
6266

6367
### Testing Database Connections
68+
6469
```bash
6570
# Connect to Neon Local database directly
6671
docker exec acquisitions-neon-local psql -U neon -d neondb
@@ -69,6 +74,7 @@ docker exec acquisitions-neon-local psql -U neon -d neondb
6974
## Architecture Overview
7075

7176
### Core Structure
77+
7278
This is a Node.js/Express REST API with a layered architecture:
7379

7480
- **Routes** (`src/routes/`) - Express route definitions and HTTP endpoint handlers
@@ -81,32 +87,38 @@ This is a Node.js/Express REST API with a layered architecture:
8187
- **Config** (`src/config/`) - Application configuration (database, logging, security)
8288

8389
### Database Architecture
90+
8491
- **ORM**: Drizzle ORM with PostgreSQL
8592
- **Provider**: Neon Database (serverless PostgreSQL)
8693
- **Development**: Uses Neon Local for ephemeral database branches
8794
- **Production**: Direct connection to Neon Cloud
8895

8996
### Security Stack
97+
9098
- **Arcjet**: Bot detection, rate limiting, and shield protection
9199
- **Helmet**: HTTP security headers
92100
- **CORS**: Cross-origin resource sharing configuration
93101
- **JWT**: Authentication tokens with role-based access
94102
- **bcrypt**: Password hashing
95103

96104
### Path Imports
105+
97106
The project uses Node.js path imports (defined in `package.json`):
107+
98108
```javascript
99109
import logger from '#config/logger.js';
100110
import { users } from '#models/user.model.js';
101111
import { createUser } from '#services/auth.service.js';
102112
```
103113

104114
### Environment Configuration
115+
105116
- `.env.development` - Development environment (with Neon Local)
106117
- `.env.production` - Production environment (direct Neon Cloud connection)
107118
- `.env.example` - Template for environment variables
108119

109120
### Key Features
121+
110122
- User authentication (signup/signin/signout) with JWT tokens
111123
- Role-based access control (admin, user, guest)
112124
- Rate limiting based on user roles (admin: 20/min, user: 10/min, guest: 5/min)
@@ -115,18 +127,22 @@ import { createUser } from '#services/auth.service.js';
115127
- Database migrations with Drizzle Kit
116128

117129
### Docker Setup
130+
118131
Two environments available:
132+
119133
- **Development**: Multi-container setup with Neon Local proxy for ephemeral databases
120134
- **Production**: Optimized single container connecting directly to Neon Cloud
121135

122136
### Development Workflow
137+
123138
1. Use Docker for consistent development environment
124139
2. Neon Local creates fresh database branches for each development session
125140
3. Hot reload enabled for code changes
126141
4. Use Drizzle Studio for database inspection
127142
5. ESLint enforces code style with 2-space indentation, single quotes, and semicolons
128143

129144
### API Endpoints
145+
130146
- `GET /` - Health check endpoint
131147
- `GET /health` - Detailed health status with uptime and memory usage
132148
- `GET /api` - API status endpoint
@@ -139,6 +155,7 @@ Two environments available:
139155
- `DELETE /api/users/:id` - Delete user (placeholder)
140156

141157
### Database Schema
158+
142159
- **Users table**: id, name, email, password (hashed), role, created_at, updated_at
143160
- Default role: "user"
144-
- Supported roles: "user", "admin"
161+
- Supported roles: "user", "admin"

drizzle.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export default {
66
dialect: 'postgresql',
77
dbCredentials: {
88
url: process.env.DATABASE_URL,
9-
}
10-
};
9+
},
10+
};

0 commit comments

Comments
 (0)