back-end-for-solana-tipjar-not-on-chain Backend for Solana TipJar - A platform enabling streamers to receive donations in SOL (Solana's cryptocurrency).
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 historyInstall the dependencies:
npm installSet the environment variables:
cp .env.example .env
# open .env and modify the environment variables (if needed)Run the app:
npm startTesting:
# run all tests
npm testThe 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=solanatipjarLINK: https://tipjar-api.onrender.com
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_nameThe name of the streamer whose messages you want to retrieve. - Response:
Endpoint:
{ "_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" }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"
}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.