Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Panmoni/pricing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YapBay & LocalSolana Pricing Server

A lightweight Express.js server that provides cryptocurrency price feeds with support for multiple fiat currencies. The server caches prices using Redis and updates them periodically via the Coinranking API.

The primary repo for this project is at: https://github.com/Panmoni/yapbay.

Features

  • Real-time USDC pricing in multiple currencies (USD, EUR, COP, NGN, VES)
  • Redis caching for improved performance
  • 15-minute automatic price updates
  • Custom handling for VES (Venezuelan Bolivar) using hardcoded rates
  • RESTful API endpoint for price queries

Prerequisites

  • Node.js
  • Redis server
  • Coinranking API key

Setup

  1. Clone the repository
  2. Install dependencies:
npm install
  1. Create a .env file with the following variables:
PORT=4000
REDIS_URL=redis://localhost:6379
COINRANKING_API_KEY=your_api_key_here
HARDCODED_VES_USD=103.99
CR_USDC_UUID=aKzUVe4Hh_CON
CR_COP_UUID=Y7N-jnLhqYiW
CR_NGN_UUID=znnRJjGM4nVb

Usage

  1. Start the Redis server
  2. Run the application:
npm start

Deployment

This service is deployed using Podman Quadlets, which provides systemd integration for containerized services.

Architecture

The deployment uses a Pod structure where the pricing server and Redis share a network namespace:

  • Pod: pricing - Provides shared network and port exposure
  • Redis Container: Cache service accessible at localhost:6379 within the pod
  • Pricing Server Container: Main application service

Quadlet Files

The deployment consists of three Quadlet files located in the deploy/ directory of this repository:

  1. pricing.pod - Pod definition with exposed ports (4000 for API, 6379 for Redis)
  2. redis.container - Redis cache service
  3. pricing-server.container - Pricing server application

See deploy/README.md for installation instructions.

Managing Services

# Check service status
systemctl --user status pricing-server.service
systemctl --user status redis.service

# View logs
journalctl --user -u pricing-server.service -f
journalctl --user -u redis.service -f

# Restart services
systemctl --user restart pricing-server.service
systemctl --user restart redis.service

# Enable auto-start on boot
systemctl --user enable pricing-server.service redis.service

# Stop services
systemctl --user stop pricing-server.service redis.service

Container Management

# View running containers
podman ps

# View pod structure
podman pod ps

# View container logs directly
podman logs pricing-server
podman logs redis

The services are configured with Restart=always, so they will automatically restart on failure.

API Endpoint

GET /price

Query Parameters:

  • token: Cryptocurrency token (e.g., USDC)
  • fiat: Fiat currency (USD, EUR, COP, NGN, VES)

Example:

GET /price?token=USDC&fiat=USD

Response:

{
  "status": "success",
  "data": {
    "price": "1.00",
    "timestamp": 1679890000
  }
}

curl http://localhost:4000/api-usage curl http://localhost:4000/price\?token\=USDC\&fiat\=NGN\&source\=binance\&type\=BUY curl http://localhost:4000/price\?token\=USDC\&fiat\=VES

x

About

The pricing server for YapBay and LocalSolana, utilizing redis in a pod for caching

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published