Skip to content

Khanhhungtran23/solana-tipjar-be

Repository files navigation

solana-tipjar-be

back-end-for-solana-tipjar-not-on-chain Backend for Solana TipJar - A platform enabling streamers to receive donations in SOL (Solana's cryptocurrency).

Installation

Clone the repo:

git clone --depth 1 https://github.com/Khanhhungtran23/solana-tipjar-be.git
cd solana-tipjar-be
npx rimraf ./.git // optional: to delete git history

Install the dependencies:

npm install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)

Commands

Run the app:

npm start

Testing:

# run all tests
npm test

Environment Variables

The environment variables can be found and modified in the .env file. They come with these default values:

# Port number
PORT=3001

# URL of the Mongo DB
MONGODB_URL=mongodb+srv://tvkhhung03:P8ZykU43fHAUg9fw@solanatipjar.lln0g.mongodb.net/?retryWrites=true&w=majority&appName=solanatipjar

Deploy on Render.com

LINK: https://tipjar-api.onrender.com

API Endpoints

List of available routes:

Endpoint: POST /m/donations/add

  • Description: Adds a new donation message.
  • :Content-Type: application/json
  • Request Body:
    {
    "transaction_signature": "string", // Transaction Signature (Tx ID)
    "donator_address": "string", // Donator Wallet Address
    "donator_name": "string", // Donator Twitch Username
    "streamer_name": "string", // Streamer Twitch Username
    "streamer_address": "string", // Streamer Wallet Address
    "amount_donated": "number", // Amount Donated (SOL)
    "message": "string"        // Donation Message  
    }
  • Response:
    {
    "_id": "string",
    "transaction_signature": "string", 
    "donator_address": "string", 
    "donator_name": "string", 
    "streamer_name": "string", 
    "streamer_address": "string", 
    "amount_sol": "number", 
    "message": "string",
    "createdAt": "string",
    "updatedAt": "string"
    }

Endpoint: GET /m/received-messages/:streamer_name

  • Description: Retrieves all donation messages for a specific streamer.
  • Parameters: :streamer_name The name of the streamer whose messages you want to retrieve.
  • Response:
    {
    "_id": "string",
    "transaction_signature": "string", 
    "donator_address": "string", 
    "donator_name": "string", 
    "streamer_name": "string", 
    "streamer_address": "string", 
    "amount_donated": "number", 
    "message": "string",
    "createdAt": "string",
    "updatedAt": "string"
    }
    Endpoint: GET /m/all-donations-mess
  • Description: Retrieves all donation messages from all streamers.
  • Response:
 {
 "_id": "string",
 "transaction_signature": "string", 
 "donator_address": "string", 
 "donator_name": "string", 
 "streamer_name": "string", 
 "streamer_address": "string", 
 "amount_donated": "number", 
 "message": "string",
 "createdAt": "string",
 "updatedAt": "string"
 }

Endpoint: GET /m/recent-mess

  • Description: Retrieves the 10 most recent donation messages.
  • Response:
 {
 "_id": "string",
 "transaction_signature": "string", 
 "donator_address": "string", 
 "donator_name": "string", 
 "streamer_name": "string", 
 "streamer_address": "string", 
 "amount_donated": "number", 
 "message": "string",
 "createdAt": "string",
 "updatedAt": "string"
 }

Error Handling:

All endpoints will return an appropriate HTTP status code and a JSON response in case of an error. Common error responses include:

  • 400 Bad Request: Invalid input or missing required fields.
  • 404 Not Found: The requested resource could not be found.
  • 500 Internal Server Error: An unexpected error occurred on the server.

About

back-end-for-solana-tipjar-not-on-chain. Deploy on render.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors