diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 07:16:23 +0200 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 07:16:23 +0200 |
| commit | 7076343338ae3439f3c86f01144818abe8c31978 (patch) | |
| tree | 794abb1e6b8f821091fd095341885496b6dad51d /html/app/routes/api.php | |
| parent | 47cbb529f5723b246125ae083a193e11481b89ef (diff) | |
| download | classroom-7076343338ae3439f3c86f01144818abe8c31978.tar.gz classroom-7076343338ae3439f3c86f01144818abe8c31978.tar.bz2 classroom-7076343338ae3439f3c86f01144818abe8c31978.zip | |
add container helpers; constuct public directory-tree
Diffstat (limited to 'html/app/routes/api.php')
| -rw-r--r-- | html/app/routes/api.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/html/app/routes/api.php b/html/app/routes/api.php new file mode 100644 index 0000000..659c25f --- /dev/null +++ b/html/app/routes/api.php @@ -0,0 +1,64 @@ +<?php + +use app\controllers\api\Common_api; +use app\controllers\api\Doc_api; + +// api: tree of product-categories +Route::add('/api/tree', + function() { Doc_api::tree(); }, + 'get' +); + +// api: database documentation +Route::add('/api/doc', + function() { Doc_api::dbDoc(); }, + 'get' +); + +Route::add('/api/url/([0-9a-zA-Z-_\/]*)', + function($url) { Common_api::category_by_url($url); } +); + +// route: /api/table +Route::add('/api/([0-9a-zA-Z-_]*)', + function($table) { Common_api::table($table); }, + 'get' +); + +// route: /api/table/{id} +Route::add('/api/([0-9a-zA-Z-_]*)/([0-9]*)', + function($table, $id) { Common_api::record($table, $id); }, + 'get' +); + + +# // 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(); +# }); + + +// route for testing... +// --- +Route::add('/test/([0-9a-zA-Z-_\/]*)', function($test) { + 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(); +}); |
