From 233d7801239dd5867191784f0642551845c17cdb Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 16 May 2019 17:31:35 +0100 Subject: [PATCH] Add link to production api.php in API docs, and change default action to a helpful message Also bump version --- Changelog.md | 3 +++ docs/05-API-Docs.md | 4 +++- logic/Actions/Index.php | 45 +++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- settings.default.toml | 2 +- version | 2 +- 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 logic/Actions/Index.php diff --git a/Changelog.md b/Changelog.md index c2e853a..7a79c6f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +# v0.9.1 - 16th May 2019 + - [API] Changed the default action. It now displays a helpful message by default instead of routing directly to `fetch-data`. + # v0.9 - 9th May 2019 - Add heatmap gauge at the right-hand-side - Display the changelog the first time a user loads the page after an update diff --git a/docs/05-API-Docs.md b/docs/05-API-Docs.md index 0b792bf..36f9b81 100644 --- a/docs/05-API-Docs.md +++ b/docs/05-API-Docs.md @@ -1,5 +1,7 @@ # API -The server-side API is accessed through `api.php`, and supports a number of GET parameters. The most important of these is the `action` parameter, Which determines what the API will do. The following values are supported: +The server-side API is accessed through `api.php`, and supports a number of GET parameters. On the main production instance, this can be found [here](https://aq.connectedhumber.org/api.php). + +The most important of these is the `action` parameter, Which determines what the API will do. The following values are supported: ## version > Returns the version of the application. diff --git a/logic/Actions/Index.php b/logic/Actions/Index.php new file mode 100644 index 0000000..b5838ba --- /dev/null +++ b/logic/Actions/Index.php @@ -0,0 +1,45 @@ +settings = $in_settings; + } + + public function handle() : bool { + global $start_time; + + $start_handle = microtime(true); + + + // 1: Parse markdown + $result = "Welcome to the Air Quality Web HTTP API! + +Although the web interface is the default thing you see, it actually uses this HTTP API as a backend - which can be interacted with directly. + +Official usage documentation for the latest version of the API can be found here: https://aq.connectedhumber.org/__nightdocs/05-API-Docs.html + +Note that if you have deployed your own version of the air quality web interface, you will need to ensure you're up-to-date with the latest commits in the \"master\" branch, otherwise the HTTP API documentation may not be completely accurate with respect to the version you're running. +"; + + + // 2: Send response + header("content-length: " . strlen($result)); + header("content-type: text/plain"); + header("x-time-taken: " . PerfFormatter::format_perf_data($start_time, $start_handle, null)); + echo($result); + return true; + } +} diff --git a/package.json b/package.json index 565a602..5e46503 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "air-quality-mapper", - "version": "0.1.0", + "version": "0.9.1", "description": "The web interface and JSON api for the ConnectedHumber Air Quality Monitoring Project.", "private": true, "main": "index.mjs", diff --git a/settings.default.toml b/settings.default.toml index 9c3f562..9a71230 100644 --- a/settings.default.toml +++ b/settings.default.toml @@ -26,7 +26,7 @@ password = "Define_in_custom_config_file" # Settings that control the router's behaviour # The default action to take if no action is specified -default-action = "fetch-data" +default-action = "index" [cache] # Settings that control how we request that appropriate API responses be cached. diff --git a/version b/version index 1bd5ffe..e6e6db4 100644 --- a/version +++ b/version @@ -1 +1 @@ -v0.9.1 +v0.9.2