diff options
Diffstat (limited to 'html/app/routes/api.php')
| -rw-r--r-- | html/app/routes/api.php | 68 |
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(); + }); |
