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.');
}

View File

@@ -17,16 +17,10 @@ error_log("Router: Resolved route for URI '{$uri}' is '{$route}'");
// Mapping routes to modules
$routes = [
'auth/login' => 'auth/login.php',
'v1/auth/login' => 'auth/login.php',
'auth/refresh' => 'auth/refresh.php',
'v1/auth/refresh' => 'auth/refresh.php',
'auth/logout' => 'auth/logout.php',
'v1/auth/logout' => 'auth/logout.php',
'users' => 'users/index.php',
'v1/users' => 'users/index.php',
'trips' => 'trips/index.php',
'v1/trips' => 'trips/index.php',
];
if (isset($routes[$route])) {

View File

@@ -31,7 +31,6 @@
<nav class="flex-1 px-4 space-y-2">
<a href="#" @click="page='dashboard'" class="block p-3 rounded hover:bg-gray-800" :class="page==='dashboard'?'bg-emerald-900/20 text-emerald-500':''">📊 لوحة التحكم</a>
<a href="#" @click="page='users'" class="block p-3 rounded hover:bg-gray-800" :class="page==='users'?'bg-emerald-900/20 text-emerald-500':''">👥 المستخدمون</a>
<a href="#" @click="page='trips'" class="block p-3 rounded hover:bg-gray-800" :class="page==='trips'?'bg-emerald-900/20 text-emerald-500':''">🚗 الرحلات</a>
</nav>
<div class="p-6 border-t border-gray-800">
<button @click="logout()" class="w-full text-right text-red-400 text-sm">🚪 تسجيل الخروج</button>
@@ -104,7 +103,7 @@
},
title() {
return { dashboard: 'لوحة التحكم', users: 'المستخدمون', trips: 'الرحلات' }[this.page];
return { dashboard: 'لوحة التحكم', users: 'المستخدمون' }[this.page];
},
async loadUsers() {