Skip to content

Dashboard API

willianpm edited this page Mar 14, 2026 · 1 revision

Dashboard API

LittleBoatPoll exposes HTTP endpoints through the Express app initialized in src/core/index.js.

Authentication

Authentication logic is in dashboard/api/auth.js.

Current behavior:

  • validateDashboardToken accepts bearer-formatted Authorization values.
  • Middleware mode returns 401 when token is missing or invalid.

Header format:

Authorization: Bearer <token>

Endpoint: Execute Command

Route:

  • POST /api/commands/:commandName

File:

  • dashboard/api/dashboard-commands.js

Request body (summary):

{
  "options": {},
  "user": { "id": "...", "username": "..." },
  "guild": { "id": "..." },
  "member": { "id": "..." },
  "permissions": []
}

Behavior:

  • Validates Authorization token.
  • Resolves command by name from client.commands.
  • Verifies bot is present in provided guild.
  • Builds an interaction-like object and executes command logic.
  • Uses a command-level lock to avoid concurrent execution collisions.

Endpoint: Upload CSV

Route:

  • POST /api/csv/upload

File:

  • dashboard/api/dashboard-csv.js

Upload constraints:

  • multipart/form-data with file field name file
  • only CSV accepted by mime type or extension
  • max file size 5 MB

Response patterns:

  • 200 on success
  • 400 for validation and upload errors
  • 401 for auth errors
  • 413 for oversized file
  • 500 for internal errors

CSV Contract

Required columns:

  • nome-da-enquete
  • opcoes
  • max_votos
  • peso_mensalistas

Delimiter:

  • semicolon (;)

See repository reference:

Clone this wiki locally