Skip to content

Latest commit

Β 

History

373 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

facilpay-api

Backend API service for FacilPay - Stellar-based multi-chain payment gateway. Handles payment processing, webhook management, settlement operations, and merchant integrations.

FacilPay API

Backend API built with NestJS.


πŸš€ Requirements

  • Docker and Docker Compose for the fastest local setup
  • Node.js 18+ and npm for running without Docker

Docker Quick Start

Start the API and PostgreSQL with hot reload:

docker compose up --build

The API will be available at http://localhost:3000.

Run database migrations inside the API container:

docker compose run --rm api migrate

Run E2E tests against a throwaway PostgreSQL database:

docker compose -f docker-compose.test.yml run --rm api test:e2e

Stop and remove local containers, networks, and volumes:

docker compose down -v

Local Setup

  1. Install dependencies
npm install

Create environment file

cp .env.example .env

Run the application

npm run start:dev

The application will be available at:

http://localhost:3000

Common Commands

npm run dev
npm test
npm run test:e2e
npm run migrate
npm run docker:dev
npm run docker:test:e2e

🩺 Health Check

To verify the API is running correctly, use the liveness probe β€” it never fails due to an external dependency and is safe for orchestrator restart checks:

curl -i http://localhost:3000/v1/health/live

Expected response (200 OK):

{
  "status": "ok",
  "statusCode": 200,
  "timestamp": "2026-01-26T10:00:00.000Z",
  "uptime": 3600
}

To check whether all dependencies (database, Stellar, Redis) are ready:

curl -i http://localhost:3000/v1/health/ready

Trimmed example response (200 OK β€” all healthy):

{
  "status": "ok",
  "statusCode": 200,
  "timestamp": "2026-01-26T10:00:00.000Z",
  "uptime": 3600,
  "services": {
    "database": { "status": "healthy", "message": "Database connection is healthy" },
    "stellar":  { "status": "healthy", "message": "Stellar network is reachable" },
    "queue":    { "status": "healthy", "message": "Redis connection is healthy" }
  }
}

See docs/HEALTH_CHECKS.md for full probe semantics and deployment examples.

πŸ” Authentication

The API includes a JWT-based authentication system with the following endpoints:

Register a new user

curl -X POST http://localhost:3000/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"password123"}'

Login user

curl -X POST http://localhost:3000/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"password123"}'

Access protected route

curl -X GET http://localhost:3000/v1/users/me \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

πŸ“ Project Structure

src/ β”œβ”€β”€ modules/ β”‚ β”œβ”€β”€ auth/ β”‚ β”‚ β”œβ”€β”€ auth.controller.ts β”‚ β”‚ β”œβ”€β”€ auth.service.ts β”‚ β”‚ β”œβ”€β”€ auth.module.ts β”‚ β”‚ β”œβ”€β”€ jwt.strategy.ts β”‚ β”‚ β”œβ”€β”€ guards/ β”‚ β”‚ └── decorators/ β”‚ β”œβ”€β”€ users/ β”‚ β”‚ β”œβ”€β”€ user.entity.ts β”‚ β”‚ β”œβ”€β”€ dto/ β”‚ β”‚ └── users.module.ts β”‚ └── health/ β”‚ β”œβ”€β”€ health.controller.ts β”‚ β”œβ”€β”€ health.service.ts β”‚ └── health.module.ts β”œβ”€β”€ app.controller.ts β”œβ”€β”€ app.service.ts β”œβ”€β”€ app.module.ts └── main.ts

πŸ§ͺ Development

The server runs on port 3000 by default.

The port can be configured using the PORT variable in the .env file

πŸ“Š Logging

Logging is structured with Pino and writes rotating files under the log directory.

Environment variables:

  • LOG_LEVEL (default: info in production, debug in development)
  • LOG_DIR (default: logs)
  • LOG_PRETTY (default: true in development, false in production)
  • LOG_MAX_SIZE (default: 10m)
  • LOG_RETENTION_DAYS (default: 14)
  • LOG_BODY (default: false)
  • LOG_BODY_MAX_LENGTH (default: 2048)
  • LOG_RESPONSE_BODY (default: false)

πŸ”’ Security Features

  • JWT token-based authentication

  • Password hashing with bcrypt

  • Protected routes with guards

  • Public route decorator

  • Current user decorator

  • Role-based access control (ready for implementation)

  • Telegram: https://t.me/+afM9uh7GGtVkYmZk

Stellar Configuration structure

β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ auth/
β”‚   β”œβ”€β”€ stellar/          <-- New Module
β”‚   β”‚   β”œβ”€β”€ stellar.service.ts
β”‚   β”‚   └── stellar.module.ts
β”‚   β”œβ”€β”€ users/
β”‚   └── health/

πŸ“š Further Documentation

About

Backend API service for FacilPay - Stellar-based multi-chain payment gateway. Handles payment processing, webhook management, settlement operations, and merchant integrations.

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages