-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
134 lines (116 loc) · 7.05 KB
/
api.php
File metadata and controls
134 lines (116 loc) · 7.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* API Entry Point
* Routes all API requests
*/
require_once __DIR__ . '/core/Database.php';
require_once __DIR__ . '/core/Router.php';
require_once __DIR__ . '/core/Response.php';
// Load controllers
require_once __DIR__ . '/modules/SeoAnalysis/SeoAnalysisController.php';
require_once __DIR__ . '/modules/Analytics/AnalyticsController.php';
require_once __DIR__ . '/modules/Monitor/MonitorController.php';
require_once __DIR__ . '/modules/Redirections/RedirectionsController.php';
require_once __DIR__ . '/modules/LocalSeo/LocalSeoController.php';
require_once __DIR__ . '/modules/ImageSeo/ImageSeoController.php';
require_once __DIR__ . '/modules/ContentAi/ContentAiController.php';
require_once __DIR__ . '/modules/Sitemap/SitemapController.php';
use RankMathWebapp\Core\Router;
use RankMathWebapp\Core\Response;
// Enable CORS for development
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Authorization');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
// Initialize router
$router = new Router();
// Add error handling middleware
$router->addMiddleware(function() {
try {
return true;
} catch (Exception $e) {
Response::serverError($e->getMessage());
return false;
}
});
// ============================================
// SEO ANALYSIS ROUTES
// ============================================
$router->post('/api/seo-analysis/analyze', 'RankMathWebapp\\Modules\\SeoAnalysis\\SeoAnalysisController@analyze');
$router->get('/api/seo-analysis/history', 'RankMathWebapp\\Modules\\SeoAnalysis\\SeoAnalysisController@getHistory');
// ============================================
// DASHBOARD ROUTES
// ============================================
$router->get('/api/dashboard/stats', 'RankMathWebapp\\Modules\\Analytics\\AnalyticsController@getDashboardStats');
// ============================================
// ANALYTICS ROUTES
// ============================================
$router->get('/api/analytics/dashboard', 'RankMathWebapp\\Modules\\Analytics\\AnalyticsController@getDashboard');
$router->post('/api/analytics/keyword', 'RankMathWebapp\\Modules\\Analytics\\AnalyticsController@addKeyword');
$router->post('/api/analytics/import-gsc', 'RankMathWebapp\\Modules\\Analytics\\AnalyticsController@importGSC');
// ============================================
// 404 MONITOR ROUTES
// ============================================
$router->get('/api/404-monitor/logs', 'RankMathWebapp\\Modules\\Monitor\\MonitorController@getLogs');
$router->post('/api/404-monitor/log', 'RankMathWebapp\\Modules\\Monitor\\MonitorController@log404');
$router->delete('/api/404-monitor/{id}', 'RankMathWebapp\\Modules\\Monitor\\MonitorController@deleteLog');
$router->post('/api/404-monitor/clear', 'RankMathWebapp\\Modules\\Monitor\\MonitorController@clearLogs');
$router->get('/api/404-monitor/export', 'RankMathWebapp\\Modules\\Monitor\\MonitorController@exportCSV');
// ============================================
// REDIRECTIONS ROUTES
// ============================================
$router->get('/api/redirections', 'RankMathWebapp\\Modules\\Redirections\\RedirectionsController@getAll');
$router->post('/api/redirections', 'RankMathWebapp\\Modules\\Redirections\\RedirectionsController@add');
$router->put('/api/redirections/{id}', 'RankMathWebapp\\Modules\\Redirections\\RedirectionsController@update');
$router->delete('/api/redirections/{id}', 'RankMathWebapp\\Modules\\Redirections\\RedirectionsController@delete');
$router->get('/api/redirections/check', 'RankMathWebapp\\Modules\\Redirections\\RedirectionsController@checkRedirect');
$router->post('/api/redirections/import', 'RankMathWebapp\\Modules\\Redirections\\RedirectionsController@importCSV');
// ============================================
// LOCAL SEO ROUTES
// ============================================
$router->get('/api/local-seo/locations', 'RankMathWebapp\\Modules\\LocalSeo\\LocalSeoController@getLocations');
$router->get('/api/local-seo/locations/{id}', 'RankMathWebapp\\Modules\\LocalSeo\\LocalSeoController@getLocation');
$router->post('/api/local-seo/locations', 'RankMathWebapp\\Modules\\LocalSeo\\LocalSeoController@addLocation');
$router->put('/api/local-seo/locations/{id}', 'RankMathWebapp\\Modules\\LocalSeo\\LocalSeoController@updateLocation');
$router->delete('/api/local-seo/locations/{id}', 'RankMathWebapp\\Modules\\LocalSeo\\LocalSeoController@deleteLocation');
$router->get('/api/local-seo/locations/{id}/schema', 'RankMathWebapp\\Modules\\LocalSeo\\LocalSeoController@getSchema');
$router->get('/api/local-seo/nearby', 'RankMathWebapp\\Modules\\LocalSeo\\LocalSeoController@searchNearby');
// ============================================
// IMAGE SEO ROUTES
// ============================================
$router->get('/api/image-seo/images', 'RankMathWebapp\\Modules\\ImageSeo\\ImageSeoController@getImages');
$router->post('/api/image-seo/analyze', 'RankMathWebapp\\Modules\\ImageSeo\\ImageSeoController@analyzeImage');
$router->put('/api/image-seo/{id}', 'RankMathWebapp\\Modules\\ImageSeo\\ImageSeoController@updateImage');
$router->post('/api/image-seo/bulk-analyze', 'RankMathWebapp\\Modules\\ImageSeo\\ImageSeoController@bulkAnalyze');
$router->get('/api/image-seo/suggest-alt', 'RankMathWebapp\\Modules\\ImageSeo\\ImageSeoController@suggestAltText');
$router->get('/api/image-seo/{id}/tips', 'RankMathWebapp\\Modules\\ImageSeo\\ImageSeoController@getOptimizationTips');
// ============================================
// CONTENT AI ROUTES
// ============================================
$router->post('/api/content-ai/generate', 'RankMathWebapp\\Modules\\ContentAi\\ContentAiController@generateContent');
$router->get('/api/content-ai/suggestions', 'RankMathWebapp\\Modules\\ContentAi\\ContentAiController@getSuggestions');
$router->get('/api/content-ai/history', 'RankMathWebapp\\Modules\\ContentAi\\ContentAiController@getHistory');
$router->post('/api/content-ai/rewrite', 'RankMathWebapp\\Modules\\ContentAi\\ContentAiController@rewriteContent');
$router->get('/api/content-ai/research', 'RankMathWebapp\\Modules\\ContentAi\\ContentAiController@researchKeyword');
// ============================================
// SITEMAP ROUTES
// ============================================
$router->get('/api/sitemap', 'RankMathWebapp\\Modules\\Sitemap\\SitemapController@getAll');
$router->post('/api/sitemap', 'RankMathWebapp\\Modules\\Sitemap\\SitemapController@add');
$router->delete('/api/sitemap/{id}', 'RankMathWebapp\\Modules\\Sitemap\\SitemapController@delete');
$router->get('/api/sitemap/generate-xml', 'RankMathWebapp\\Modules\\Sitemap\\SitemapController@generateXML');
$router->post('/api/sitemap/crawl', 'RankMathWebapp\\Modules\\Sitemap\\SitemapController@crawlAndGenerate');
// ============================================
// HEALTH CHECK
// ============================================
$router->get('/api/health', function() {
Response::success('API is running', [
'version' => '1.0.0',
'timestamp' => time(),
]);
});
// Dispatch the request
$router->dispatch();