-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
36 lines (28 loc) · 913 Bytes
/
index.php
File metadata and controls
36 lines (28 loc) · 913 Bytes
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
<?php
@include_once "./utils/httpException.php";
@include_once "./app/app.controller.php";
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token, Authorization');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
return 0;
exit;
}
# Disable errors, should be false in production
# error_reporting(false);
# Check if function loaded successfully, or throw error
if (!function_exists("httpException")) {
echo json_encode([
"message" => "Runtime error",
"statusCode" => 500
]);
exit;
}
# Safely load config
unset($dbConfig);
@include "./db/db.config.php";
if (empty($dbConfig)) {
httpException("Config load error", 500)['end']();
}
# Setup app
$app = new AppController($dbConfig);