Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
84ced24
feat: introduce virtual account generation with a new Prisma model an…
codepraycode Dec 13, 2025
59000ad
feat: Implement virtual account creation with Globus integration, ban…
codepraycode Dec 13, 2025
31753b5
feat: Add banking webhook handling, update socket authentication, and…
codepraycode Dec 13, 2025
471c7d7
docs: expand documentation on Socket.io security, Dead Letter Queue, …
codepraycode Dec 13, 2025
b1aaa87
feat: Implement webhook signature verification using raw body, add id…
codepraycode Dec 13, 2025
eb207df
feat: Implement transfer functionality with beneficiary management, n…
codepraycode Dec 13, 2025
f7cda8d
feat: Include virtual account details in user wallet data, centralize…
codepraycode Dec 13, 2025
941d79b
refactor: Restructure server architecture, migrate to shared modules,…
codepraycode Dec 13, 2025
86e8b65
feat: implement Redis-backed PIN lockout, prevent self-transfers, and…
codepraycode Dec 13, 2025
dc31a7f
feat: Introduce P2P exchange module with order, ad, payment method, a…
codepraycode Dec 13, 2025
dd7e18d
feat: Implement avatar uploads with S3/R2 storage, P2P chat image upl…
codepraycode Dec 13, 2025
228aff6
feat: Implement admin module with dispute resolution, admin managemen…
codepraycode Dec 13, 2025
71707c7
docs: Convert admin implementation plan to detailed module documentat…
codepraycode Dec 13, 2025
4c77ce3
docs: Reorganize documentation into guides and archive, update Docker…
codepraycode Dec 13, 2025
1b4470c
feat: Add system module with dedicated routes and update API collecti…
codepraycode Dec 13, 2025
0cedcf7
feat: Add ESLint and Prettier for code quality, improve environment v…
codepraycode Dec 13, 2025
4d2a78b
feat: Enhance Redis connection robustness and logging, update environ…
codepraycode Dec 13, 2025
f66c380
refactor: Update dependencies, simplify error handling, and reorganiz…
codepraycode Dec 16, 2025
f904436
feat: Apply authentication middleware to all subsequent routes and ad…
codepraycode Dec 16, 2025
75d8095
feat: Implement transfer idempotency, refine auth token handling, imp…
codepraycode Dec 16, 2025
43275e3
refactor: destructure `saveBeneficiary`, `accountNumber`, and `bankCo…
codepraycode Dec 16, 2025
66c2f99
feat: Centralize `userId` extraction with `JwtUtils.ensureAuthenticat…
codepraycode Dec 16, 2025
db453ef
refactor: centralize user ID extraction with `JwtUtils.ensureAuthenti…
codepraycode Dec 16, 2025
b51b915
feat: Add granular email and phone verification fields, update verifi…
codepraycode Dec 17, 2025
fc4cf63
refactor: relocate transfer module to a dedicated API module, add rea…
codepraycode Dec 17, 2025
bb7a08f
feat: Replace `transaction_update` socket events with `WALLET_UPDATED…
codepraycode Dec 17, 2025
9f4e87e
feat: Implement user management features including profile updates, p…
codepraycode Dec 17, 2025
0ee9cd8
feat: send debit alert push notification to the sender and document i…
codepraycode Dec 17, 2025
c31e71a
feat: Implement `counterpartyId` for transactions with schema updates…
codepraycode Dec 17, 2025
b6b0f08
feat: Implement a comprehensive notification system and refactor P2P …
codepraycode Dec 17, 2025
4df657d
feat: emit socket event when sending notification to user
codepraycode Dec 17, 2025
6a4ae26
feat: Automatically upgrade user KYC to BASIC upon successful email a…
codepraycode Dec 17, 2025
c26c907
Prepare for deployment
codepraycode Dec 17, 2025
a15a977
feat: Introduce staging deployment mode with conditional Globus crede…
codepraycode Dec 17, 2025
ee1cace
Fix render.yaml schema errors and add Redis manual setup instructions
codepraycode Dec 17, 2025
3f6ce28
feat: Add documentation for using Resend without a custom domain for …
codepraycode Dec 17, 2025
dc9102c
Update PostgreSQL plan from deprecated 'starter' to 'free'
codepraycode Dec 17, 2025
9425024
feat: add Railway deployment support with setup script, configuration…
codepraycode Dec 17, 2025
669deb2
fix: correct test import paths and types
codepraycode Dec 17, 2025
aa88163
fix: expose health check at /api/v1/health for railway
codepraycode Dec 17, 2025
b0fe244
Fix: Server not starting
codepraycode Dec 17, 2025
048364e
fix: Install openssl in Dockerfile to resolve Prisma generation issue…
codepraycode Dec 17, 2025
14349e5
build: Run database deployment during Docker image build.
codepraycode Dec 17, 2025
3319165
build: use npm for db deployment command
codepraycode Dec 17, 2025
ccae3ff
fix: correct npm db:deploy command execution
codepraycode Dec 17, 2025
fe59652
chore: Remove `npm run db:deploy` from Dockerfile.
codepraycode Dec 17, 2025
26c2dd0
refactor: Restructure notification module and centralize shared servi…
codepraycode Dec 17, 2025
01694c6
feat: Remove dedicated script for deploying database migrations.
codepraycode Dec 17, 2025
d8f87b2
refactor: Reorganize deployment and implementation documentation into…
codepraycode Dec 17, 2025
7fd1a82
feat: improve environment variable loading robustness and explicitly …
codepraycode Dec 17, 2025
8b2a07f
chore: Comment out explicit LOG_LEVEL configuration for logger and co…
codepraycode Dec 17, 2025
ba28bb0
feat: enable `LOG_LEVEL` configuration for logger and console transport
codepraycode Dec 17, 2025
7e7dca1
feat: add debug logs to server startup and database connection checks
codepraycode Dec 17, 2025
d2e7dda
chore: Add debug logs for file loading in env.config and logger modules.
codepraycode Dec 17, 2025
972ee57
chore: Add debug logs to environment validation process.
codepraycode Dec 17, 2025
870ce1c
chore: Add debug console logs to key modules and relax socket service…
codepraycode Dec 17, 2025
7254aa1
chore: Add debug logs to indicate app and routes module loading.
codepraycode Dec 17, 2025
d497597
chore: add debug logs to indicate when route modules are loaded.
codepraycode Dec 17, 2025
f70d8ad
checking for hand
codepraycode Dec 17, 2025
e3055c3
chore: add debug log to auth routes
codepraycode Dec 17, 2025
a3c3eab
debug: Add console logs for service loading in auth and onboarding qu…
codepraycode Dec 17, 2025
0dd9b9b
chore: Add debug log for Redis config loading.
codepraycode Dec 17, 2025
898aba1
refactor: wrap onboarding queue initialization in a try-catch block w…
codepraycode Dec 17, 2025
e18ccd9
feat: Disable onboarding queue functionality during user registration.
codepraycode Dec 17, 2025
6a96d93
chore: Add debug loading logs to email, OTP, and SMS services.
codepraycode Dec 17, 2025
810e9bd
chore: Add debug log to resend email service loading.
codepraycode Dec 17, 2025
b836fd7
refactor: update service import paths and add debug logs in OtpServic…
codepraycode Dec 18, 2025
86d4056
refactor: centralize BullMQ queue and service initialization with a n…
codepraycode Dec 18, 2025
6fab8d5
refactor: relocate Globus banking service and its tests to shared ser…
codepraycode Dec 18, 2025
801c5f5
feat: Add verification success email, integrate Resend email service,…
codepraycode Dec 18, 2025
2f7838c
refactor: Disable SMS sending for phone verification, two-factor, and…
codepraycode Dec 18, 2025
5af5c96
feat: enable SMS sending for phone-related OTP types and log email in…
codepraycode Dec 18, 2025
44d4bfb
feat: conditionally skip Globus signature verification in staging env…
codepraycode Dec 18, 2025
8d69eaa
feat: Add warning level logging to API error constructors.
codepraycode Dec 18, 2025
a0c2e59
feat: Introduce a two-step transfer flow with PIN verification and id…
codepraycode Dec 19, 2025
7b8c3dc
feat: Add Mailtrap email service for staging environments, including …
codepraycode Dec 19, 2025
1b2f138
feat: Add SendGrid email service and migrate Mailtrap to its API for …
codepraycode Dec 19, 2025
b448ea1
chore: Add Mailtrap debugging utilities and clear old deployment erro…
codepraycode Dec 19, 2025
ef22eed
chore: Comment out specific email service imports and environment con…
codepraycode Dec 19, 2025
5990816
refactor: consolidate auth and user into account module, refactor tra…
codepraycode Dec 24, 2025
d2307d2
refactor: consolidate auth and user into account module, refactor tra…
codepraycode Dec 24, 2025
9acd667
docs: Archive existing documentation files into the `archive` subdire…
codepraycode Dec 24, 2025
b616369
chore: Add logs directory to .gitignore.
codepraycode Dec 24, 2025
9f1e1dc
chore: Relocate `db-manager.sh` and `setup.sh` to `scripts/` and upda…
codepraycode Dec 24, 2025
29f693b
docs: add Expo Push setup guide and Postman testing instructions for …
codepraycode Dec 24, 2025
f1b048f
feat: Introduce comprehensive audit logging with a dedicated service,…
codepraycode Dec 24, 2025
2aa0554
docs: Add audit module documentation covering its architecture, backe…
codepraycode Dec 24, 2025
63bd45d
feat: Implement KYC verification and refactor OTP service to use Redis**
codepraycode Dec 24, 2025
1b104de
feat: Overhaul authentication system with new middlewares, event-driv…
codepraycode Dec 25, 2025
9e6a591
feat: Implement ledger-based internal transfers with transfer fees an…
codepraycode Dec 25, 2025
d329f45
feat: Implement P2P trading module with services for ads, orders, cha…
codepraycode Dec 25, 2025
3fe1476
refactor: standardize authentication middleware import paths and add …
codepraycode Dec 25, 2025
c695063
feat: Add multi-step registration, KYC submission endpoints, and syst…
codepraycode Dec 25, 2025
d5b2415
feat: Add `slugify` utility, apply it to file naming, and enhance val…
codepraycode Dec 25, 2025
46d8e5d
feat: Implement refresh token functionality and refactor user registr…
codepraycode Dec 28, 2025
6e86a5d
feat: Introduce 2-step transfer flow with PIN verification, idempoten…
codepraycode Dec 28, 2025
9043643
docs: Update P2P order and chat API endpoints, including method chang…
codepraycode Dec 28, 2025
f2dd7e4
refactor: Overhaul KYC system with unified submission, asynchronous p…
codepraycode Dec 30, 2025
4d87e1d
feat: add 'STALE' to `KycStatus` enum and set it as the default for `…
codepraycode Dec 30, 2025
9f4be90
feat: Implement profile avatar upload, enhance OTP send validation, u…
codepraycode Dec 31, 2025
f490529
feat: Return P2P orders with ad, maker, and taker relations from the …
codepraycode Dec 31, 2025
8ba93be
refactor: Decouple P2P order fund release to an asynchronous worker a…
codepraycode Dec 31, 2025
65d38f5
feat: Require payment proof for marking orders as paid, integrating i…
codepraycode Dec 31, 2025
4bb35e0
feat: Add user P2P order listing, refine order confirmation logic, an…
codepraycode Dec 31, 2025
b0dcb82
feat: enhance P2P order transaction records with detailed balance tra…
codepraycode Dec 31, 2025
5664d58
refactor: consolidate P2P services, add `processing` order status, an…
codepraycode Dec 31, 2025
3bff5e6
feat: Implement P2P ad cleanup worker and queue, and add a mobile int…
codepraycode Dec 31, 2025
2181b6b
feat: Filter P2P ads below their minimum limit, correct order confirm…
codepraycode Dec 31, 2025
b62f9f3
update: ready
codepraycode Dec 31, 2025
cc8fc15
feat: Implement P2P payment proof authorization for FX sender, add co…
codepraycode Jan 1, 2026
6b6c40a
feat: add P2P documentation, refactor auth password management, enhan…
codepraycode Jan 2, 2026
77d2a4b
feat: Integrate Twilio SMS and refine email service with Resend/SendG…
codepraycode Jan 2, 2026
53be17c
feat: Implement modular storage service with Cloudinary, S3, and loca…
codepraycode Jan 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
114 changes: 80 additions & 34 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,40 +1,86 @@
# Environment configuration
NODE_ENV=development # development or test or production
PORT=3002
# Server Configuration
NODE_ENV=development
PORT=3001
SERVER_URL=http://localhost:3001
ENABLE_FILE_LOGGING=true
LOG_LEVEL="error"
SERVER_URL="http://localhost"

# Database configuration
DB_HOST="localhost"
DB_PORT=5433
DB_USER="swaplink_user"
DB_PASSWORD="swaplink_password"
DB_NAME="swaplink_test"
DATABASE_URL="postgresql://swaplink_user:swaplink_password@localhost:5433/swaplink_test" # based on the docker config

# Redis
REDIS_URL="redis://localhost:6380"
REDIS_PORT=6380

# JWT
JWT_SECRET="test_jwt_secret_key_123"
JWT_REFRESH_SECRET="test_refresh_secret_key_123"
JWT_ACCESS_EXPIRATION=24h
JWT_REFRESH_EXPIRATION=7d

# Payment Providers
GLOBUS_SECRET_KEY="test_mono_secret"
GLOBUS_WEBHOOK_SECRET="test_webhook_secret"
# Database Configuration
DB_HOST=localhost
DB_USER=swaplink_user
DB_PASSWORD=swaplink_password
DB_NAME=swaplink_mvp
# Note: Port 5434 is for dev (docker-compose.yml), 5433 is for test (docker-compose.test.yml)
DATABASE_URL=postgresql://swaplink_user:swaplink_password@localhost:5434/swaplink_mvp

# Redis Configuration
# Note: Port 6381 is for dev (docker-compose.yml), 6380 is for test (docker-compose.test.yml)
REDIS_URL=redis://localhost:6381
REDIS_PORT=6381

# JWT Configuration
JWT_SECRET=your_jwt_secret_key_here
JWT_ACCESS_EXPIRATION=15m
JWT_REFRESH_SECRET=your_jwt_refresh_secret_key_here
JWT_REFRESH_EXPIRATION=7d

# CORS (seperated by comma)
CORS_URLS="http://localhost:3001"
# Globus Bank API Configuration
GLOBUS_SECRET_KEY=your_globus_secret_key
GLOBUS_WEBHOOK_SECRET=your_globus_webhook_secret
GLOBUS_BASE_URL=https://sandbox.globusbank.com/api
GLOBUS_CLIENT_ID=your_globus_client_id

# CORS Configuration
CORS_URLS=http://localhost:3000

# Email configuration
SMTP_HOST="smtp.example.com"
# Email Configuration (SMTP)
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER="user@example.com"
SMTP_PASSWORD="password"
EMAIL_TIMEOUT=5000
FROM_EMAIL="from@example.com"
SMTP_USER=your_smtp_user
SMTP_PASSWORD=your_smtp_password
EMAIL_TIMEOUT=10000
FROM_EMAIL=onboarding@resend.dev

# Resend Email Service (Primary - Recommended)
# Get your API key from https://resend.com/api-keys
# Free tier: 100 emails/day, 3,000/month
RESEND_API_KEY=re_your_resend_api_key_here

# SendGrid Email Service (Fallback - Optional)
# Get your API key from https://app.sendgrid.com/settings/api_keys
SENDGRID_API_KEY=SG.your_sendgrid_api_key_here

# Mailtrap Email Service (Staging - Fallback)
# Get your API token from https://mailtrap.io/api-tokens
MAILTRAP_API_TOKEN=your_mailtrap_api_token_here

# Mailtrap SMTP (Deprecated - kept for backward compatibility)
# Note: SMTP may not work on Railway/cloud platforms due to port restrictions
MAILTRAP_HOST=sandbox.smtp.mailtrap.io
MAILTRAP_PORT=2525
MAILTRAP_USER=
MAILTRAP_PASSWORD=

# Twilio SMS Service
# Get your credentials from https://console.twilio.com/
TWILIO_ACCOUNT_SID=your_twilio_account_sid_here
TWILIO_AUTH_TOKEN=your_twilio_auth_token_here
TWILIO_PHONE_NUMBER=+1234567890

# Frontend Configuration
FRONTEND_URL=http://localhost:3000

# Cloudinary Storage Service (Primary)
# Get credentials from https://cloudinary.com/console
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

# Storage Configuration (S3/Cloudflare R2/MinIO)
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_REGION=us-east-1
AWS_BUCKET_NAME=swaplink
AWS_ENDPOINT=http://localhost:9000

# System Configuration
SYSTEM_USER_ID=system-wallet-user
73 changes: 73 additions & 0 deletions .env.staging.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Server Configuration
NODE_ENV=staging
PORT=3001
SERVER_URL=http://localhost:3001
ENABLE_FILE_LOGGING=true
STAGING=true

# Database Configuration
DB_HOST=localhost
DB_USER=swaplink_user
DB_PASSWORD=swaplink_password
DB_NAME=swaplink_staging
# Note: Port 5434 is for dev (docker-compose.yml)
DATABASE_URL=postgresql://swaplink_user:swaplink_password@localhost:5434/swaplink_staging

# Redis Configuration
# Note: Port 6381 is for dev (docker-compose.yml)
REDIS_URL=redis://localhost:6381
REDIS_PORT=6381

# JWT Configuration
JWT_SECRET=your_jwt_secret_key_here
JWT_ACCESS_EXPIRATION=15m
JWT_REFRESH_SECRET=your_jwt_refresh_secret_key_here
JWT_REFRESH_EXPIRATION=7d

# Globus Bank API Configuration (Optional for staging)
GLOBUS_SECRET_KEY=your_globus_secret_key
GLOBUS_WEBHOOK_SECRET=your_globus_webhook_secret
GLOBUS_BASE_URL=https://sandbox.globusbank.com/api
GLOBUS_CLIENT_ID=your_globus_client_id

# CORS Configuration
CORS_URLS=http://localhost:3000

# Email Configuration (SMTP) - Not used when Mailtrap is configured
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your_smtp_user
SMTP_PASSWORD=your_smtp_password
EMAIL_TIMEOUT=10000
FROM_EMAIL=no-reply@swaplink.com

# Resend Email Service (Not used in staging)
RESEND_API_KEY=

# SendGrid Email Service (Staging - Recommended for Railway/Cloud)
# Get your API key from https://app.sendgrid.com/settings/api_keys
SENDGRID_API_KEY=SG.your_sendgrid_api_key_here

# Mailtrap Email Service (Staging - Local Development Fallback)
# Get your API token from https://mailtrap.io/api-tokens
MAILTRAP_API_TOKEN=your_mailtrap_api_token_here

# Mailtrap SMTP (Deprecated - kept for backward compatibility)
# Note: SMTP may not work on Railway/cloud platforms due to port restrictions
MAILTRAP_HOST=sandbox.smtp.mailtrap.io
MAILTRAP_PORT=2525
MAILTRAP_USER=
MAILTRAP_PASSWORD=

# Frontend Configuration
FRONTEND_URL=http://localhost:3000

# Storage Configuration (S3/Cloudflare R2/MinIO)
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_REGION=us-east-1
AWS_BUCKET_NAME=swaplink
AWS_ENDPOINT=http://localhost:9000

# System Configuration
SYSTEM_USER_ID=system-wallet-user
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
coverage
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"env": {
"node": true,
"es6": true
},
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"no-console": ["warn", { "allow": ["warn", "error", "info"] }]
}
}
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ node_modules
.env*
.env.*
!.env.example
!.env.staging.example

generated
dist
dist

# Test Output
test_output.txt
test_output*.txt

# User data
uploads
swaplink-demo-firebase-adminsdk-fbsvc-ebfd2ff064.json

# logs
logs
*.log

# Agents
.agent
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Unified Dockerfile for SwapLink Server (API & Worker)
FROM node:18-alpine AS builder

WORKDIR /app

# Install pnpm
# Install pnpm and openssl
RUN apk add --no-cache openssl && npm install -g pnpm

# Copy package files
COPY package.json pnpm-lock.yaml ./

# Install dependencies (frozen lockfile for consistency)
RUN pnpm install --frozen-lockfile

# Copy Prisma schema and generate client
COPY prisma ./prisma
RUN pnpm db:generate

# Copy source code
COPY . .

# Build TypeScript
RUN pnpm build

# Prune dev dependencies to keep image small
ENV CI=true
RUN pnpm prune --prod

# --- Runner Stage ---
FROM node:18-alpine AS runner

WORKDIR /app

# Install openssl
RUN apk add --no-cache openssl

# Copy package files
COPY package.json pnpm-lock.yaml ./

# Copy production node_modules from builder (preserves pnpm structure and Prisma client)
COPY --from=builder /app/node_modules ./node_modules

# Copy built artifacts
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma

# Expose API port
EXPOSE 3000

# Default command (can be overridden in docker-compose)
CMD ["node", "dist/api/server.js"]
Loading