Skip to content
MozzaBotAltPublic

About

Backend of MozzaBot Websites

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

145 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

General API of MozzaBot Websites

GAPIM

Backend API of All MozzaBot Sites

Introduction

Use of this is for educational purposes only

URL to API

URL to API is as listed below:

API Endpoints

General Endpoints

  • GET / - Server status check
  • GET /ip - Returns client's IP address
  • GET /date - Redirects to /api/date
  • GET /dev - Redirects to /api/dev

API Routes (/api)

  • GET /api/date - Returns current date
  • GET /api/dev - Returns all employees
  • GET /api/dev/:id - Returns specific employee by ID
  • POST /api/addemployee - Add new employee (requires first_name and last_name in body)

Hmm

Send JSON with a non-empty message string (maximum 10,000 characters); userId and metadata are optional. Configure DATABASE_URL, or PGHOST, PGDATABASE, PGUSER, and PGPASSWORD. Locally, the backend reads backend/.env or backend/process.env; on hosts, set SECRETS_FILE or provide environment variables directly. The backend allows cross-origin requests from any site. Set TRUST_PROXY_HOPS to the number of trusted reverse proxies in production. Never commit populated secret files.

QRAG artwork API

The QRAG artwork API is mounted at /api/artworks:

  • GET /api/artworks - List up to 200 artworks, newest first.
  • GET /api/artworks?id=<id> or GET /api/artworks?barcode_id=<id> - Fetch an artwork by its barcode UUID or legacy qr_id. The ARTWORK: barcode prefix is optional. Returns 404 when no artwork matches.
  • POST /api/artworks - Create an artwork using multipart/form-data fields title (required), description (optional), and image (required file). Returns 201 and the saved artwork.
  • PUT /api/artworks?id=<id> - Update at least one of title, description, or image using multipart/form-data. Requires the x-admin-token header.

Artwork responses contain qr_id, barcode_id, title, description, artist, year, medium, image_url, image_public_id, accent, created_at, and updated_at. Titles are limited to 160 characters, descriptions to 5,000 characters, and images to 10 MB by default (JPEG, PNG, or WebP); MAX_UPLOAD_BYTES can change the upload limit. PostgreSQL is required. Image creation and replacement also require Cloudinary credentials via CLOUDINARY_URL or CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, and CLOUDINARY_API_SECRET; CLOUDINARY_FOLDER optionally selects the upload folder. Configure a random ADMIN_API_TOKEN of at least 32 bytes for update access. The database schema is initialized during backend startup and upgrades existing artwork tables without removing legacy IDs.

MyPNG calculator API

  • GET /api/grade-thresholds - Return saved grade thresholds and their updatedAt time.
  • PUT /api/grade-thresholds - Save { "grades": [...] }; requires Authorization: Bearer <ADMIN_API_KEY>.

The grade list must contain, in order, A+, A, A-, B+, B, C+, C, D, E, and G; mark thresholds must descend to 0, and points must be between 0 and 20. The server creates and seeds the grade_thresholds table during startup using the provisional values from backend/MyPNGCalculator/migrations/001_create_grade_thresholds.sql. Confirm official mark bands and points before operational use. The student calculator uses the stored points to calculate PNG as SUM(point × creditHours) / SUM(creditHours).

Set ADMIN_API_KEY for calculator updates. For QRAG updates, set a separate ADMIN_API_TOKEN (at least 32 bytes); do not expose either credential to browser code.

The integrated server exposes GET /health, which checks PostgreSQL connectivity. CORS allows requests from any browser origin. CORS is not authentication, so protect sensitive endpoints with their normal credentials.

JSON settings storage

  • GET /infositemrsm - Pull the saved settings JSON document
  • POST /infositemrsm - Push a new settings JSON document
  • PUT /infositemrsm - Replace the saved settings JSON document

The json_documents table stores slides, announcements, and settings in separate PostgreSQL JSONB columns. It also retains the full request body in data so the existing API response format remains unchanged. On startup, existing documents are backfilled into the separate columns, and the infositemrsm document is initialized from settings/n.json when that file is present. If it is absent, the default is one blank slide (with template 1 and duration 5), empty announcements, and settings.slidingText set to an empty string. settings/m.json lists the available slide template IDs.

Example:

curl -X PUT http://gapim.onrender.com/infositemrsm \
  -H "Content-Type: application/json" \
  -d '{"slides":[{"title":"Welcome","message":"Hello","duration":5,"template":1}],"announcements":[],"settings":{"slidingText":"Welcome!"}}'

curl http://gapim.onrender.com/infositemrsm

POST returns 201 Created; PUT replaces the same document and returns 200 OK. Both methods accept a JSON request body, and GET returns the stored JSON directly. The existing database connection settings above are required.

Webhooks

  • POST /github/webhooks/ - GitHub webhook handler for issues and ping events

Bugs?

Bugs? Any ideas for improvements? Feedback? Tell us on:

  1. 231046@langkawi.mrsm.edu.my

Credits

Credits:

  1. Ali Mozzabot I... Team Principal... Website Developer... Github
  2. Eiko... Right Hand Man(RHM)... Graphic Designer... Github

Notes

To do list:

  1. Security: resource

About

Backend of MozzaBot Websites

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages