Update: 2026-05-03 20:47:13

This commit is contained in:
Hamza-Ayed
2026-05-03 20:47:13 +03:00
parent bc35319f3c
commit b0e79fd214
3 changed files with 1 additions and 36 deletions

View File

@@ -1,28 +0,0 @@
<?php
/**
* Trips List Endpoint (Example Module)
*/
use App\Core\Database;
use App\Middleware\AuthMiddleware;
use App\Middleware\RateLimitMiddleware;
// 1. Rate Limiting (e.g., 30 requests per minute)
RateLimitMiddleware::check(30, 60);
// 2. Auth Check
$decoded = AuthMiddleware::check();
// 3. Fetch Data
// Note: Assumes a 'trips' table exists based on the requested structure
$db = Database::getInstance();
try {
$stmt = $db->prepare("SELECT * FROM trips WHERE user_id = ? ORDER BY created_at DESC");
$stmt->execute([$decoded['user_id']]);
$trips = $stmt->fetchAll();
json_success($trips);
} catch (\PDOException $e) {
// If table doesn't exist, return empty for the sake of the skeleton
json_success([], 'Trips table not found, returning empty array for demonstration.');
}