Spaces:
Running
Running
Разработай полноценную систему для автоматического создания REST API к базе данных PostgreSQL со следующими возможностями: Основные требования Интерфейс управления API Веб-интерфейс для настройки и управления API Возможность выбора конкретных таблиц базы данных для экспозиции через API Визуальное отображение структуры таблиц и связей между ними Функциональность API Только операции чтения (GET-запросы) Поддержка фильтрации данных по различным полям Возможность сортировки и пагинации результатов Поддержка базовых агрегатных функций (COUNT, SUM, AVG) Система авторизации Механизм аутентификации пользователей (JWT или OAuth 2.0) Разграничение доступа к разным таблицам для разных пользователей Управление API-ключами и их ограничениями Техническая реализация Автоматическая генерация документации API (Swagger/OpenAPI) Журналирование запросов для мониторинга и отладки Защита от SQL-инъекций и других атак Кэширование часто запрашиваемых данных Система должна быть простой в использовании даже для пользователей без глубоких технических знаний, но достаточно гибкой для продвинутых сценариев использования. - Initial Deployment
Browse filesFiles changed (2)
- README.md+7-5
- index.html+521-19
12345678910---title: Api Manageremoji: 🚀colorFrom: yellowcolorTo: pinksdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112---title: api-manageremoji: 🐳colorFrom: greencolorTo: bluesdk: staticpinned: falsetags:- deepsite---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>REST API Manager for PostgreSQL</title><script src="https://cdn.tailwindcss.com"></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><script>tailwind.config = {theme: {extend: {colors: {primary: '#4361ee',secondary: '#3f37c9',dark: '#1e293b',success: '#10b981',warning: '#f59e0b',danger: '#ef4444',info: '#3b82f6'}}}}</script><style>:root {--sidebar-width: 250px;}.sidebar {width: var(--sidebar-width);transition: all 0.3s;}.main-content {margin-left: var(--sidebar-width);transition: all 0.3s;}.collapsed .sidebar {width: 60px;}.collapsed .main-content {margin-left: 60px;}.table-view {max-height: calc(100vh - 200px);overflow-y: auto;}.api-method {width: 80px;}.draggable-item {cursor: move;}.swagger-ui {max-height: calc(100vh - 150px);overflow-y: auto;}@media (max-width: 768px) {.sidebar {width: 60px;}.main-content {margin-left: 60px;}.collapsed .sidebar {width: 0;}.collapsed .main-content {margin-left: 0;}}</style></head><body class="bg-gray-100"><div id="app" class="min-h-screen flex"><!-- Sidebar --><div class="sidebar bg-dark text-white fixed h-screen overflow-y-auto z-30"><div class="p-4 border-b border-gray-700 flex items-center"><i class="fas fa-database text-xl mr-3 text-primary"></i><span class="font-bold text-lg">API Manager</span></div><ul class="mt-5"><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center active"><i class="fas fa-tachometer-alt mr-3"></i><span>Dashboard</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-table mr-3"></i><span>Database Tables</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-wrench mr-3"></i><span>API Configuration</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-shield-alt mr-3"></i><span>Authentication</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-book mr-3"></i><span>API Documentation</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-history mr-3"></i><span>Request Logs</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-key mr-3"></i><span>API Keys</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-users mr-3"></i><span>Users</span></li><li class="py-3 px-4 hover:bg-gray-700 cursor-pointer flex items-center"><i class="fas fa-cog mr-3"></i><span>Settings</span></li></ul></div><!-- Main Content --><div class="main-content flex-1"><!-- Header --><header class="bg-white shadow py-4 px-6 flex justify-between items-center"><div><button class="p-2 rounded-md hover:bg-gray-200 text-dark"><i class="fas fa-bars text-xl"></i></button></div><div class="flex items-center"><div class="relative mr-4"><i class="fas fa-bell text-xl text-gray-600"></i><span class="absolute -top-1 -right-1 bg-danger text-white rounded-full text-xs w-5 h-5 flex items-center justify-center">3</span></div><div class="flex items-center"><img src="https://ui-avatars.com/api/?name=Admin&background=4361ee&color=fff" alt="Admin" class="w-8 h-8 rounded-full mr-2"><span class="hidden md:block">Admin</span></div></div></header><!-- Dashboard Content --><div class="p-6"><!-- Status Cards --><div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8"><div class="bg-white p-6 rounded-lg shadow"><div class="flex justify-between"><div><p class="text-gray-500">Active APIs</p><p class="text-2xl font-bold mt-2">14</p></div><div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center"><i class="fas fa-plug text-blue-600 text-xl"></i></div></div></div><div class="bg-white p-6 rounded-lg shadow"><div class="flex justify-between"><div><p class="text-gray-500">Monthly Requests</p><p class="text-2xl font-bold mt-2">48.2K</p></div><div class="bg-green-100 w-12 h-12 rounded-full flex items-center justify-center"><i class="fas fa-chart-line text-green-600 text-xl"></i></div></div></div><div class="bg-white p-6 rounded-lg shadow"><div class="flex justify-between"><div><p class="text-gray-500">API Users</p><p class="text-2xl font-bold mt-2">26</p></div><div class="bg-purple-100 w-12 h-12 rounded-full flex items-center justify-center"><i class="fas fa-users text-purple-600 text-xl"></i></div></div></div><div class="bg-white p-6 rounded-lg shadow"><div class="flex justify-between"><div><p class="text-gray-500">Errors</p><p class="text-2xl font-bold mt-2">12</p></div><div class="bg-red-100 w-12 h-12 rounded-full flex items-center justify-center"><i class="fas fa-exclamation-triangle text-red-600 text-xl"></i></div></div></div></div><!-- API Endpoints --><div class="bg-white rounded-lg shadow mb-8"><div class="p-4 border-b"><h2 class="text-lg font-semibold">API Endpoints</h2></div><div class="p-4"><div class="mb-4"><input type="text" placeholder="Search endpoints..." class="w-full p-3 border rounded-lg"></div><div class="overflow-x-auto"><table class="min-w-full"><thead class="bg-gray-50"><tr><th class="py-3 px-4 text-left">Method</th><th class="py-3 px-4 text-left">Endpoint</th><th class="py-3 px-4 text-left">Description</th><th class="py-3 px-4 text-left">Status</th><th class="py-3 px-4 text-left">Actions</th></tr></thead><tbody class="divide-y"><tr><td class="py-3 px-4"><span class="api-method bg-green-100 text-green-800 py-1 px-2 rounded text-sm">GET</span></td><td class="py-3 px-4 font-mono">/api/users</td><td class="py-3 px-4">Retrieve all users</td><td class="py-3 px-4"><span class="bg-green-100 text-green-800 py-1 px-2 rounded-full text-xs">Active</span></td><td class="py-3 px-4"><button class="p-1 text-blue-500 hover:text-blue-700"><i class="fas fa-edit"></i></button><button class="p-1 text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button></td></tr><tr><td class="py-3 px-4"><span class="api-method bg-green-100 text-green-800 py-1 px-2 rounded text-sm">GET</span></td><td class="py-3 px-4 font-mono">/api/products</td><td class="py-3 px-4">Retrieve all products</td><td class="py-3 px-4"><span class="bg-green-100 text-green-800 py-1 px-2 rounded-full text-xs">Active</span></td><td class="py-3 px-4"><button class="p-1 text-blue-500 hover:text-blue-700"><i class="fas fa-edit"></i></button><button class="p-1 text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button></td></tr><tr><td class="py-3 px-4"><span class="api-method bg-green-100 text-green-800 py-1 px-2 rounded text-sm">GET</span></td><td class="py-3 px-4 font-mono">/api/orders</td><td class="py-3 px-4">Retrieve all orders</td><td class="py-3 px-4"><span class="bg-green-100 text-green-800 py-1 px-2 rounded-full text-xs">Active</span></td><td class="py-3 px-4"><button class="p-1 text-blue-500 hover:text-blue-700"><i class="fas fa-edit"></i></button><button class="p-1 text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button></td></tr><tr><td class="py-3 px-4"><span class="api-method bg-blue-100 text-blue-800 py-1 px-2 rounded text-sm">GET</span></td><td class="py-3 px-4 font-mono">/api/orders/{id}</td><td class="py-3 px-4">Retrieve order details</td><td class="py-3 px-4"><span class="bg-yellow-100 text-yellow-800 py-1 px-2 rounded-full text-xs">Draft</span></td><td class="py-3 px-4"><button class="p-1 text-blue-500 hover:text-blue-700"><i class="fas fa-edit"></i></button><button class="p-1 text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button></td></tr></tbody></table></div></div></div><!-- Recent Activity --><div class="grid grid-cols-1 lg:grid-cols-2 gap-6"><div class="bg-white rounded-lg shadow"><div class="p-4 border-b"><h2 class="text-lg font-semibold">Recent Activity</h2></div><div class="p-4"><div class="space-y-4"><div class="flex items-start"><div class="bg-blue-100 p-2 rounded-full mr-3"><i class="fas fa-plus text-blue-600"></i></div><div class="flex-1"><p class="font-medium">New endpoint created</p><p class="text-gray-600 text-sm">/api/products endpoint was added</p><p class="text-gray-400 text-xs">2 hours ago</p></div></div><div class="flex items-start"><div class="bg-green-100 p-2 rounded-full mr-3"><i class="fas fa-check text-green-600"></i></div><div class="flex-1"><p class="font-medium">Endpoint activated</p><p class="text-gray-600 text-sm">/api/users endpoint is now active</p><p class="text-gray-400 text-xs">5 hours ago</p></div></div><div class="flex items-start"><div class="bg-red-100 p-2 rounded-full mr-3"><i class="fas fa-exclamation text-red-600"></i></div><div class="flex-1"><p class="font-medium">High traffic detected</p><p class="text-gray-600 text-sm">/api/orders received 1240 requests in last hour</p><p class="text-gray-400 text-xs">Yesterday</p></div></div><div class="flex items-start"><div class="bg-yellow-100 p-2 rounded-full mr-3"><i class="fas fa-cog text-yellow-600"></i></div><div class="flex-1"><p class="font-medium">Configuration updated</p><p class="text-gray-600 text-sm">Caching settings for products were modified</p><p class="text-gray-400 text-xs">2 days ago</p></div></div></div></div></div><!-- API Performance --><div class="bg-white rounded-lg shadow"><div class="p-4 border-b"><h2 class="text-lg font-semibold">API Performance</h2></div><div class="p-4"><div class="flex items-center justify-between mb-4"><p>Response Times (ms)</p><div class="flex"><button class="text-xs px-2 py-1 bg-gray-100 rounded-l">24h</button><button class="text-xs px-2 py-1 bg-primary text-white rounded-r">7d</button></div></div><div class="h-48 bg-gray-100 rounded flex items-center justify-center mb-4"><div class="text-center"><i class="fas fa-chart-bar text-4xl text-gray-300 mb-2"></i><p class="text-gray-500">Performance chart</p></div></div><div class="space-y-2"><div class="flex justify-between"><div><span class="inline-block w-3 h-3 bg-primary rounded-full mr-2"></span><span>Average Response</span></div><span>142 ms</span></div><div class="flex justify-between"><div><span class="inline-block w-3 h-3 bg-success rounded-full mr-2"></span><span>Success Rate</span></div><span>98.4%</span></div><div class="flex justify-between"><div><span class="inline-block w-3 h-3 bg-danger rounded-full mr-2"></span><span>Error Rate</span></div><span>1.6%</span></div></div></div></div></div></div></div></div><script>// Mock database tables for demonstrationconst databaseTables = [{name: 'users',columns: [{name: 'id', type: 'integer', primaryKey: true},{name: 'username', type: 'varchar(50)'},{name: 'email', type: 'varchar(100)'},{name: 'created_at', type: 'timestamp'},{name: 'role', type: 'varchar(20)'}],endpoint: '/api/users',status: 'active'},{name: 'products',columns: [{name: 'id', type: 'integer', primaryKey: true},{name: 'name', type: 'varchar(255)'},{name: 'price', type: 'numeric(10,2)'},{name: 'category', type: 'varchar(50)'},{name: 'stock', type: 'integer'},{name: 'created_at', type: 'timestamp'}],endpoint: '/api/products',status: 'active'},{name: 'orders',columns: [{name: 'id', type: 'integer', primaryKey: true},{name: 'user_id', type: 'integer', foreignKey: 'users.id'},{name: 'product_id', type: 'integer', foreignKey: 'products.id'},{name: 'quantity', type: 'integer'},{name: 'total_price', type: 'numeric(10,2)'},{name: 'created_at', type: 'timestamp'}],endpoint: '/api/orders',status: 'draft'}];// Mock API endpointsconst apiEndpoints = [{method: 'GET',path: '/api/users',description: 'Retrieve all users',status: 'active',filters: ['id', 'username', 'email', 'role'],sorting: ['id', 'username', 'created_at'],authentication: 'JWT'},{method: 'GET',path: '/api/products',description: 'Retrieve all products',status: 'active',filters: ['id', 'name', 'category', 'price'],sorting: ['id', 'name', 'price'],authentication: 'API Key'},{method: 'GET',path: '/api/orders',description: 'Retrieve all orders',status: 'draft',filters: ['id', 'user_id', 'product_id'],sorting: ['id', 'created_at'],authentication: 'JWT'}];// Mock users for demonstrationconst users = [{id: 1, username: 'admin', role: 'Administrator', email: 'admin@company.com', createdAt: '2023-05-12'},{id: 2, username: 'manager', role: 'Manager', email: 'manager@company.com', createdAt: '2023-06-01'},{id: 3, username: 'developer', role: 'Developer', email: 'dev@company.com', createdAt: '2023-07-15'},{id: 4, username: 'client1', role: 'Client', email: 'client1@business.com', createdAt: '2023-08-20'},];// Mock API keysconst apiKeys = [{id: 1, key: 'a1b2c3d4e5f6', name: 'Mobile App', status: 'active', rateLimit: 1000, permissions: ['read:users', 'read:products']},{id: 2, key: 'x7y8z9abcdef', name: 'Web Dashboard', status: 'active', rateLimit: 5000, permissions: ['read:all']},{id: 3, key: 'ghijklmnopqr', name: 'Internal Script', status: 'inactive', rateLimit: 100, permissions: ['read:orders']},];// Initialize sidebar togglingdocument.addEventListener('DOMContentLoaded', function() {const sidebarToggle = document.querySelector('header button');const app = document.getElementById('app');sidebarToggle.addEventListener('click', function() {app.classList.toggle('collapsed');});// Initialize tab switchingconst sidebarItems = document.querySelectorAll('.sidebar li');sidebarItems.forEach(item => {item.addEventListener('click', function() {sidebarItems.forEach(i => i.classList.remove('active'));this.classList.add('active');// In a real app, we would load the appropriate content for each tabconst title = this.querySelector('span').textContent;document.querySelector('header + .p-6').innerHTML = `<div class="bg-white p-6 rounded-lg shadow text-center"><h1 class="text-2xl font-bold mb-4">${title}</h1><p class="text-gray-600">Content for ${title} would be displayed here</p></div>`;});});});</script><p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Pervyh/api-manager" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body></html>
README.md+7-5
index.html+521-19