summaryrefslogtreecommitdiff
path: root/html/app/routes/api.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-30 05:03:23 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-30 05:03:23 +0300
commit4f2d900af7636e6744ae14aeeefdf2d6080ac50a (patch)
tree1f80775437510591656e6ef13375516226ed27f3 /html/app/routes/api.php
parenta16d070c4f8301a8b68220aca6d3573705be9025 (diff)
downloadclassroom-4f2d900af7636e6744ae14aeeefdf2d6080ac50a.tar.gz
classroom-4f2d900af7636e6744ae14aeeefdf2d6080ac50a.tar.bz2
classroom-4f2d900af7636e6744ae14aeeefdf2d6080ac50a.zip
several mail options tested; mailhog (fake) mailer is working
Diffstat (limited to 'html/app/routes/api.php')
-rw-r--r--html/app/routes/api.php68
1 files changed, 49 insertions, 19 deletions
diff --git a/html/app/routes/api.php b/html/app/routes/api.php
index 659c25f..ecf15fb 100644
--- a/html/app/routes/api.php
+++ b/html/app/routes/api.php
@@ -1,8 +1,17 @@
<?php
+use app\controllers\Auth;
use app\controllers\api\Common_api;
use app\controllers\api\Doc_api;
+
+/** API CALLS
+ * -----------------------------------------------------------------------------
+ *
+ * these calls return json responses
+ */
+
+
// api: tree of product-categories
Route::add('/api/tree',
function() { Doc_api::tree(); },
@@ -32,33 +41,54 @@ Route::add('/api/([0-9a-zA-Z-_]*)/([0-9]*)',
);
-# // test on the go
-# // find products with large differences on price between stores
-# // ---
-# Route::add('/api/price-diffs', function() {
-# $wtf = Registry::use('database')->runQuery("SELECT sku,
-# max(ProductPrice_OriginalPrice) as MX,
-# min(ProductPrice_OriginalPrice) as MN,
-# ((max(ProductPrice_OriginalPrice)-min(ProductPrice_OriginalPrice))/max(ProductPrice_OriginalPrice)) as Di
-# FROM prices
-# GROUP BY sku
-# ORDER BY Di desc
-# LIMIT 300",
-# []
-# );
-# reply_json([
-# 'success' => true,
-# 'result' => $wtf
-# ]); die();
-# });
+
+/** XML CALLS
+ * -----------------------------------------------------------------------------
+ *
+ * These calls are like `/api`, except...
+ * they return xml/html as part of the responses;
+ *
+ * example: { success: true, message: html }
+ *
+ * Used when an html message needs to be passed in some div
+ *
+ */
+
+
+// user sends a registration form;
+Route::add('/xml/register', function() { $x = Auth::register(); print_r($x); }, 'post');
+
+
+// user sends a confirmation request (alongside with some 'account' token)
+Route::add('/xml/confirm-account', function() { Auth::confirm_account(); } );
+
+
+// user sends a reset password request)
+Route::add('/xml/reset-password', function() { Auth::confirm(); } );
+
+
+
+
+/** TEST CALLS
+ * -----------------------------------------------------------------------------
+ *
+ * direct calls to simple tests
+ *
+ */
+
// route for testing...
// ---
Route::add('/test/([0-9a-zA-Z-_\/]*)', function($test) {
+
+ // TODO:
+ // hide tests from production
+
if (file_exists(TESTS_DIRECTORY . $test .'.php')) {
if (!Benchmark::exist('start')) Benchmark::add_spot('start');
require(TESTS_DIRECTORY . $test .'.php');
} else { echo "Test {$test} not exist";
} die();
+
});