diff --git a/src/APIlite.php b/src/APIlite.php
index e2a7149..0460714 100644
--- a/src/APIlite.php
+++ b/src/APIlite.php
@@ -29,6 +29,8 @@ class APIlite
} else {
if (isset($_REQUEST['format']) && $_REQUEST['format'] == 'html') {
$this->printHelpHTML();
+ } elseif (isset($_REQUEST['format']) && $_REQUEST['format'] == 'typescript') {
+ $this->printHelpTypescript();
} else {
$this->printHelpJSON();
}
@@ -148,6 +150,7 @@ class APIlite
$this->response(array(
'name' => $this->apiName,
'html_version' => $this->getCurrentUrl().'?format=html',
+ 'typescript_version' => $this->getCurrentUrl().'?format=typescript',
'actions' => $this->methods
));
}
@@ -157,6 +160,14 @@ class APIlite
include __DIR__ . '/help.tpl.php';
}
+ private function printHelpTypescript(): void
+ {
+ ob_clean();
+ header('Content-Type: application/javascript');
+ header('Content-Disposition: attachment; filename="' . $this->apiName . '.js"');
+ include __DIR__ . '/typescript.tpl.php';
+ }
+
private function getCurrentUrl(): string {
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ||
$_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
@@ -178,6 +189,10 @@ class APIlite
private function doAction(string $action): void
{
+ if ($action == '__HELP__') {
+ $this->printHelpJSON();
+ return;
+ }
$method = $this->getMethod($action);
if (is_null($method)) {
$this->responseERROR('Action "' . $action . '" not found');
diff --git a/src/help.tpl.php b/src/help.tpl.php
index 6ccfae7..0602b46 100644
--- a/src/help.tpl.php
+++ b/src/help.tpl.php
@@ -182,6 +182,14 @@
margin-left: 0.5rem;
}
+ /* Footer */
+ .footer {
+ background-color: #F4F5F8;
+ padding: 2rem 0;
+ text-align: center;
+ margin-top: 3rem;
+ }
+
/* Responsive design */
@media (max-width: 768px) {
.container {
@@ -253,8 +261,8 @@
@@ -303,6 +311,15 @@
+
+
+