Skip to content

Commit 4c5c586

Browse files
committed
initial commit
0 parents  commit 4c5c586

File tree

298 files changed

+111618
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

298 files changed

+111618
-0
lines changed

.env.example

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Zuplo API Gateway Configuration
2+
3+
# Database
4+
DATABASE_URL=postgresql://postgres:password@localhost:5432/zuplo_gateway
5+
REDIS_URL=redis://localhost:6379
6+
7+
# API Gateway
8+
PORT=3000
9+
NODE_ENV=development
10+
LOG_LEVEL=info
11+
12+
# Authentication
13+
JWT_SECRET=your-super-secret-jwt-key-change-in-production
14+
ADMIN_API_KEY=admin-super-secret-key-change-in-production
15+
16+
# Rate Limiting
17+
RATE_LIMIT_WINDOW_MS=60000
18+
RATE_LIMIT_MAX_REQUESTS=1000
19+
20+
# Monitoring
21+
PROMETHEUS_ENABLED=true
22+
METRICS_PORT=9090
23+
24+
# Webhooks
25+
WEBHOOK_SECRET=your-webhook-secret-key
26+
27+
# Stripe (for monetization)
28+
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
29+
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
30+
31+
# Email (for notifications)
32+
SMTP_HOST=smtp.gmail.com
33+
SMTP_PORT=587
34+
SMTP_USER=your-email@gmail.com
35+
SMTP_PASS=your-app-password
36+
37+
# External Services
38+
GITHUB_CLIENT_ID=your-github-client-id
39+
GITHUB_CLIENT_SECRET=your-github-client-secret

.eslintrc.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
es2021: true,
5+
},
6+
extends: [
7+
'eslint:recommended',
8+
],
9+
parserOptions: {
10+
ecmaVersion: 12,
11+
sourceType: 'module',
12+
},
13+
rules: {
14+
'indent': ['error', 2],
15+
'linebreak-style': ['error', 'unix'],
16+
'quotes': ['error', 'single'],
17+
'semi': ['error', 'always'],
18+
'no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }],
19+
'no-console': 'warn',
20+
'prefer-const': 'error',
21+
'no-var': 'error',
22+
},
23+
globals: {
24+
'process': 'readonly',
25+
'Buffer': 'readonly',
26+
'__dirname': 'readonly',
27+
'__filename': 'readonly',
28+
'module': 'readonly',
29+
'require': 'readonly',
30+
'exports': 'readonly',
31+
'global': 'readonly',
32+
'console': 'readonly',
33+
}
34+
};

.github/workflows/ci-cd.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
NODE_VERSION: '18'
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
18+
services:
19+
postgres:
20+
image: postgres:15
21+
env:
22+
POSTGRES_PASSWORD: test_password
23+
POSTGRES_USER: test_user
24+
POSTGRES_DB: test_db
25+
options: >-
26+
--health-cmd pg_isready
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
30+
ports:
31+
- 5432:5432
32+
33+
redis:
34+
image: redis:7-alpine
35+
options: >-
36+
--health-cmd "redis-cli ping"
37+
--health-interval 10s
38+
--health-timeout 5s
39+
--health-retries 5
40+
ports:
41+
- 6379:6379
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: ${{ env.NODE_VERSION }}
51+
cache: 'npm'
52+
53+
- name: Install dependencies
54+
run: npm ci
55+
56+
- name: Run linting
57+
run: npm run lint
58+
59+
- name: Run tests
60+
run: npm test
61+
env:
62+
DATABASE_URL: postgresql://test_user:test_password@localhost:5432/test_db
63+
REDIS_URL: redis://localhost:6379
64+
JWT_SECRET: test-jwt-secret
65+
ADMIN_API_KEY: test-admin-key
66+
67+
- name: Run security audit
68+
run: npm audit --audit-level moderate
69+
70+
build:
71+
needs: test
72+
runs-on: ubuntu-latest
73+
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v4
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: Log in to Container Registry
82+
uses: docker/login-action@v3
83+
with:
84+
registry: ${{ env.REGISTRY }}
85+
username: ${{ github.actor }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Extract metadata
89+
id: meta
90+
uses: docker/metadata-action@v5
91+
with:
92+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
93+
tags: |
94+
type=ref,event=branch
95+
type=ref,event=pr
96+
type=sha,prefix={{branch}}-
97+
type=raw,value=latest,enable={{is_default_branch}}
98+
99+
- name: Build and push Docker image
100+
uses: docker/build-push-action@v5
101+
with:
102+
context: .
103+
push: true
104+
tags: ${{ steps.meta.outputs.tags }}
105+
labels: ${{ steps.meta.outputs.labels }}
106+
cache-from: type=gha
107+
cache-to: type=gha,mode=max
108+
109+
deploy:
110+
needs: [test, build]
111+
runs-on: ubuntu-latest
112+
if: github.ref == 'refs/heads/main'
113+
114+
steps:
115+
- name: Checkout code
116+
uses: actions/checkout@v4
117+
118+
- name: Deploy to staging
119+
run: |
120+
echo "Deploying to staging environment..."
121+
# Add your deployment commands here
122+
# Example: kubectl apply -f k8s/
123+
# Example: docker-compose -f docker-compose.prod.yml up -d
124+
125+
- name: Run smoke tests
126+
run: |
127+
echo "Running smoke tests..."
128+
# Add smoke test commands here
129+
# Example: curl -f http://staging.example.com/health
130+
131+
- name: Notify deployment
132+
if: always()
133+
run: |
134+
echo "Deployment completed with status: ${{ job.status }}"
135+
# Add notification logic (Slack, email, etc.)
136+
137+
security-scan:
138+
runs-on: ubuntu-latest
139+
140+
steps:
141+
- name: Checkout code
142+
uses: actions/checkout@v4
143+
144+
- name: Run Trivy vulnerability scanner
145+
uses: aquasecurity/trivy-action@master
146+
with:
147+
scan-type: 'fs'
148+
scan-ref: '.'
149+
format: 'sarif'
150+
output: 'trivy-results.sarif'
151+
152+
- name: Upload Trivy scan results
153+
uses: github/codeql-action/upload-sarif@v2
154+
if: always()
155+
with:
156+
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)