Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DavidCevallos15/Crucidrive---APP/llms.txt

Use this file to discover all available pages before exploring further.

Passengers call this endpoint to place a tricimoto ride request. The server accepts decimal coordinates for both the pickup and drop-off points, converts them to PostGIS GEOGRAPHY(POINT) format using WKT notation, and persists a new row in public.viajes with a status of "solicitado" and a fixed tariff of $1.50. Available conductors can then see the request and accept it. Access: requires the pasajero role. The route is protected by authMiddleware followed by roleMiddleware(['pasajero']), which reads the caller’s role from public.perfiles and rejects conductors or unauthenticated users.

Request

Authorization
string
required
Bearer JWT from Supabase Auth. The authenticated user must have rol = "pasajero" in public.perfiles.
origen
object
required
Pickup coordinates as a JSON object with lat (latitude) and lng (longitude) expressed as decimal numbers. Both lat and lng are validated server-side.
destino
object
required
Drop-off coordinates as a JSON object with lat and lng expressed as decimal numbers. Only destino.lat is validated server-side; destino.lng is accepted without an explicit null-check in the current implementation.

Example request body

{
  "origen": { "lat": -1.0448, "lng": -80.5432 },
  "destino": { "lat": -1.0470, "lng": -80.5485 }
}

Response 201

id
string
Auto-generated UUID for the new ride record.
pasajero_id
string
UUID of the passenger who requested the ride — sourced from req.user.id.
origen
string
Pickup point stored as a WKT string, e.g. "POINT(-80.5432 -1.0448)". Longitude is listed first per the WKT standard.
destino
string
Drop-off point stored as a WKT string, e.g. "POINT(-80.5485 -1.0470)".
estado
string
Always "solicitado" on creation. Transitions to "aceptado" when a conductor claims the ride.
tarifa
number
Fixed ride fare in USD. Always 1.50 at this time.
created_at
string
ISO 8601 timestamp set by the database at insert time.

Error cases

HTTP statusCause
400origen or destino is missing, or origen.lat, origen.lng, or destino.lat is missing (note: the current validation checks origen.lng twice and does not separately validate destino.lng)
400Database insert error — e.g. a foreign-key violation on pasajero_id

Full curl example

curl -X POST https://api.crucidrive.local/api/viajes/solicitar \
  -H "Authorization: Bearer <your_access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "origen": { "lat": -1.0448, "lng": -80.5432 },
    "destino": { "lat": -1.0470, "lng": -80.5485 }
  }'
{
  "status": "success",
  "message": "Viaje solicitado correctamente.",
  "data": {
    "id": "c3d4e5f6-0000-0000-0000-aabbccddeeff",
    "pasajero_id": "a1b2c3d4-0000-0000-0000-111122223333",
    "conductor_id": null,
    "origen": "POINT(-80.5432 -1.0448)",
    "destino": "POINT(-80.5485 -1.047)",
    "estado": "solicitado",
    "tarifa": 1.50,
    "created_at": "2024-11-15T14:22:00.000Z",
    "updated_at": null
  }
}
The tariff is currently hardcoded at $1.50 for all rides in Crucita. A future release will replace this with a dynamic, sector-based tariff grid that accounts for distance zones within the town.
Coordinates are stored as POINT(lng lat)longitude first, then latitude — which is the WKT standard and what PostGIS GEOGRAPHY columns expect. This is the reverse of the { lat, lng } order used in the request body. The conversion is handled automatically by the toWKT(lng, lat) utility before the DB insert.

Build docs developers (and LLMs) love