{"id":31756713,"url":"https://github.com/mk590901/toit-rest-api-db","last_synced_at":"2026-02-16T13:32:55.572Z","repository":{"id":313624588,"uuid":"1052056544","full_name":"mk590901/toit-rest-api-db","owner":"mk590901","description":"The repository contains a modified application https://github.com/mk590901/toit-rest-api. The application additionally saves meteo information to the cloud in Firebase Realtime Database.","archived":false,"fork":false,"pushed_at":"2025-09-08T04:46:01.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-09T19:22:09.527Z","etag":null,"topics":["firebase-realtime-database","mqtt-client","rest-api","toit"],"latest_commit_sha":null,"homepage":"","language":"Toit","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mk590901.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-07T10:07:43.000Z","updated_at":"2025-09-08T04:46:04.000Z","dependencies_parsed_at":"2025-09-07T12:24:39.915Z","dependency_job_id":"08c86545-4c42-4741-bcdc-fc1356f4d402","html_url":"https://github.com/mk590901/toit-rest-api-db","commit_stats":null,"previous_names":["mk590901/toit-rest-api-db"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mk590901/toit-rest-api-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk590901%2Ftoit-rest-api-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk590901%2Ftoit-rest-api-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk590901%2Ftoit-rest-api-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk590901%2Ftoit-rest-api-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mk590901","download_url":"https://codeload.github.com/mk590901/toit-rest-api-db/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk590901%2Ftoit-rest-api-db/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29509130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firebase-realtime-database","mqtt-client","rest-api","toit"],"created_at":"2025-10-09T19:21:57.738Z","updated_at":"2026-02-16T13:32:55.566Z","avatar_url":"https://github.com/mk590901.png","language":"Toit","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloud DB Access on TOIT\n\nBelow description of modified application https://github.com/mk590901/toit-rest-api. The application additionally saves meteo information to the cloud in __Firebase Realtime Database__.\n\n## Introduction\n\nThe application is a clone of the previously mentioned application, which allows you to receive specific meteorological information upon request from a third-party __MQTT__ client for some geographic point. The received information is also saved in the __Firebase RealTime DataBase__ on the cloud now.\n\nThis saved data is shown below in the movie on the __Firebase console__.\n\n## Brief description\n\nThere are two things to pay attention to in the application:\n* Construction of a json object for sending to the DB: several procedures in the __utils.toit__ file, which are used after receiving weather data in __weather.toit__ module.\n* The __send_firebase__ procedure in __firebase.toit__ file, which implements sending data to __Firebase Realtime Database__.\n\n## Implementation\n\nThe application consists of two parts:\n\u003e MQTT client in the _mqtt_bridge.toit_ file, which allows\n* Receive data for a request pair [city, country code]. For example, \"Tokyo, JP\", \"Jerusalem, IL\" or \"Rovaniemi, FI\", \n* Create and execute a request using the __doneRequest__ function and send the received weather data to the desired topic via the __MQTT__ bridge.\n* By means __getJson__ function to get a __json object__ that contains data to add to the __Firebase Realtime Database__.\n* Finally, the __send_firebase__ function performs posting data to add them to the cloud.\n\u003e The __doneRequest__ function, in the _weather.toit_ file, which receives data for a request and returns a json string with current weather data. In parallel, this function generates data in a form suitable for storage in the __Firebase Realtime Database__. \n\nNB! Details on using __HTTP__ requests in __TOIT__ can be found at https://docs.toit.io/tutorials/network/http.\n\n[firebase.webm](https://github.com/user-attachments/assets/dd140081-9d7a-44fa-bfb2-66d51f8050b2)\n\n\n## Application management\n\n\u003e Installing packages:\n\n* __mqtt__\n```\n$ jag pkg install github.com/toitware/mqtt@v2\n```\n* __http__\n```\n$ jag pkg install github.com/toitlang/pkg-http@v2\n```\n* __certificate-roots__\n```\n$ jag pkg install github.com/toitware/toit-cert-roots@v1\n```\n\n\u003e Loading the application:\n\n```\nmicrcx@micrcx-desktop:~/toit/rest_db$ jag run -d midi mqtt_bridge.toit\nScanning for device with name: 'midi'\nRunning 'mqtt_bridge.toit' on 'midi' ...\nSuccess: Sent 148KB code to 'midi' in 3.57s\nmicrcx@micrcx-desktop:~/toit/rest_db$\n```\n\n\u003e Monitoring\n```\n[jaguar] INFO: program 858c7914-0f48-9842-500e-27359b97cd25 started\nDEBUG: connected to broker\nDEBUG: connection established\nConnected to MQTT broker broker.hivemq.com\nReceived: weather_out/topic: {\"request\":\"Nuuk,GL\"}\nReceived message on 'weather_out/topic': {\"request\":\"Nuuk,GL\"}\nhasRequest-\u003etrue hasCmd-\u003efalse\nrequest-\u003eNuuk,GL\nprocessing-\u003e[Nuuk,GL]\nanswer-\u003e[{\"Location\":\"Nuuk,GL, (64.18, -51.74)\",\"Temperature\":\"1.20 °C\",\"Wind Speed\":\"5.80 km/h\",\"Surface Pressure\":\"1001.00 (hPa)\",\"Relative Humidity\":\"92.00 %\",\"Precipitation\":\"0.00 mm\"}]\njson_db-\u003e[{\"Location\":{\"City\":\"Nuuk\",\"Country code\":\"GL\",\"Latitude\":64.18,\"Longitude\":-51.74},\"Temperature\":{\"Value\":1.20,\"Units\":\"°C\"},\"Wind Speed\":{\"Value\":5.80,\"Units\":\"km/h\"},\"Surface Pressure\":{\"Value\":1001.00,\"Units\":\"hPa\"},\"Relative Humidity\":{\"Value\":92,\"Units\":\"%\"},\"Precipitation\":{\"Value\":0.00,\"Units\":\"mm\"}}]\nRecord successfully created: {name: -OZXsg_odPZ4oN56Zbcm}\nReceived: weather_out/topic: {\"request\":\"Santiago,CL\"}\nReceived message on 'weather_out/topic': {\"request\":\"Santiago,CL\"}\nhasRequest-\u003etrue hasCmd-\u003efalse\nrequest-\u003eSantiago,CL\nprocessing-\u003e[Santiago,CL]\nanswer-\u003e[{\"Location\":\"Santiago,CL, (-33.44, -70.65)\",\"Temperature\":\"8.60 °C\",\"Wind Speed\":\"5.10 km/h\",\"Surface Pressure\":\"950.00 (hPa)\",\"Relative Humidity\":\"88.00 %\",\"Precipitation\":\"0.00 mm\"}]\njson_db-\u003e[{\"Location\":{\"City\":\"Santiago\",\"Country code\":\"CL\",\"Latitude\":-33.44,\"Longitude\":-70.65},\"Temperature\":{\"Value\":8.60,\"Units\":\"°C\"},\"Wind Speed\":{\"Value\":5.10,\"Units\":\"km/h\"},\"Surface Pressure\":{\"Value\":950.00,\"Units\":\"hPa\"},\"Relative Humidity\":{\"Value\":88,\"Units\":\"%\"},\"Precipitation\":{\"Value\":0.00,\"Units\":\"mm\"}}]\nRecord successfully created: {name: -OZXshiO-IerBiuRSdsR}\nReceived: weather_out/topic: {\"request\":\"Washington,US\"}\nReceived message on 'weather_out/topic': {\"request\":\"Washington,US\"}\nhasRequest-\u003etrue hasCmd-\u003efalse\nrequest-\u003eWashington,US\nprocessing-\u003e[Washington,US]\nanswer-\u003e[{\"Location\":\"Washington,US, (38.90, -77.04)\",\"Temperature\":\"18.90 °C\",\"Wind Speed\":\"7.60 km/h\",\"Surface Pressure\":\"1011.20 (hPa)\",\"Relative Humidity\":\"83.00 %\",\"Precipitation\":\"0.00 mm\"}]\njson_db-\u003e[{\"Location\":{\"City\":\"Washington\",\"Country code\":\"US\",\"Latitude\":38.90,\"Longitude\":-77.04},\"Temperature\":{\"Value\":18.90,\"Units\":\"°C\"},\"Wind Speed\":{\"Value\":7.60,\"Units\":\"km/h\"},\"Surface Pressure\":{\"Value\":1011.20,\"Units\":\"hPa\"},\"Relative Humidity\":{\"Value\":83,\"Units\":\"%\"},\"Precipitation\":{\"Value\":0.00,\"Units\":\"mm\"}}]\nRecord successfully created: {name: -OZXsjfD_huguUtvNFM5}\nReceived: weather_out/topic: {\"request\":\"Paris,FR\"}\nReceived message on 'weather_out/topic': {\"request\":\"Paris,FR\"}\nhasRequest-\u003etrue hasCmd-\u003efalse\nrequest-\u003eParis,FR\nprocessing-\u003e[Paris,FR]\nanswer-\u003e[{\"Location\":\"Paris,FR, (48.86, 2.32)\",\"Temperature\":\"16.60 °C\",\"Wind Speed\":\"7.70 km/h\",\"Surface Pressure\":\"1007.10 (hPa)\",\"Relative Humidity\":\"77.00 %\",\"Precipitation\":\"0.00 mm\"}]\njson_db-\u003e[{\"Location\":{\"City\":\"Paris\",\"Country code\":\"FR\",\"Latitude\":48.86,\"Longitude\":2.32},\"Temperature\":{\"Value\":16.60,\"Units\":\"°C\"},\"Wind Speed\":{\"Value\":7.70,\"Units\":\"km/h\"},\"Surface Pressure\":{\"Value\":1007.10,\"Units\":\"hPa\"},\"Relative Humidity\":{\"Value\":77,\"Units\":\"%\"},\"Precipitation\":{\"Value\":0.00,\"Units\":\"mm\"}}]\nRecord successfully created: {name: -OZXsmk765KCottf12s7}\nE (211557) wifi:CCMP replay detected: A1=10:20:ba:32:1d:14 A2=0c:9d:92:4c:83:a8 PN=363, RSC=364 seq=0\nReceived: weather_out/topic: {\"request\":\"Paris,FR\"}\nReceived message on 'weather_out/topic': {\"request\":\"Paris,FR\"}\nhasRequest-\u003etrue hasCmd-\u003efalse\nrequest-\u003eParis,FR\nprocessing-\u003e[Paris,FR]\nanswer-\u003e[{\"Location\":\"Paris,FR, (48.86, 2.32)\",\"Temperature\":\"16.60 °C\",\"Wind Speed\":\"7.70 km/h\",\"Surface Pressure\":\"1007.10 (hPa)\",\"Relative Humidity\":\"77.00 %\",\"Precipitation\":\"0.00 mm\"}]\njson_db-\u003e[{\"Location\":{\"City\":\"Paris\",\"Country code\":\"FR\",\"Latitude\":48.86,\"Longitude\":2.32},\"Temperature\":{\"Value\":16.60,\"Units\":\"°C\"},\"Wind Speed\":{\"Value\":7.70,\"Units\":\"km/h\"},\"Surface Pressure\":{\"Value\":1007.10,\"Units\":\"hPa\"},\"Relative Humidity\":{\"Value\":77,\"Units\":\"%\"},\"Precipitation\":{\"Value\":0.00,\"Units\":\"mm\"}}]\nRecord successfully created: {name: -OZXtSw1m-BBQDiR93VZ}\nReceived: weather_out/topic: {\"request\":\"Lisbon,PT\"}\nReceived message on 'weather_out/topic': {\"request\":\"Lisbon,PT\"}\nhasRequest-\u003etrue hasCmd-\u003efalse\nrequest-\u003eLisbon,PT\nprocessing-\u003e[Lisbon,PT]\nanswer-\u003e[{\"Location\":\"Lisbon,PT, (38.71, -9.14)\",\"Temperature\":\"19.80 °C\",\"Wind Speed\":\"7.70 km/h\",\"Surface Pressure\":\"1009.90 (hPa)\",\"Relative Humidity\":\"88.00 %\",\"Precipitation\":\"0.00 mm\"}]\njson_db-\u003e[{\"Location\":{\"City\":\"Lisbon\",\"Country code\":\"PT\",\"Latitude\":38.71,\"Longitude\":-9.14},\"Temperature\":{\"Value\":19.80,\"Units\":\"°C\"},\"Wind Speed\":{\"Value\":7.70,\"Units\":\"km/h\"},\"Surface Pressure\":{\"Value\":1009.90,\"Units\":\"hPa\"},\"Relative Humidity\":{\"Value\":88,\"Units\":\"%\"},\"Precipitation\":{\"Value\":0.00,\"Units\":\"mm\"}}]\nRecord successfully created: {name: -OZXtU0Z8m04n2YCtpeE}\nReceived: weather_out/topic: {\"request\":\"Beijing,CN\"}\nReceived message on 'weather_out/topic': {\"request\":\"Beijing,CN\"}\nhasRequest-\u003etrue hasCmd-\u003efalse\nrequest-\u003eBeijing,CN\nprocessing-\u003e[Beijing,CN]\nanswer-\u003e[{\"Location\":\"Beijing,CN, (39.91, 116.39)\",\"Temperature\":\"31.80 °C\",\"Wind Speed\":\"9.00 km/h\",\"Surface Pressure\":\"1000.90 (hPa)\",\"Relative Humidity\":\"19.00 %\",\"Precipitation\":\"0.00 mm\"}]\njson_db-\u003e[{\"Location\":{\"City\":\"Beijing\",\"Country code\":\"CN\",\"Latitude\":39.91,\"Longitude\":116.39},\"Temperature\":{\"Value\":31.80,\"Units\":\"°C\"},\"Wind Speed\":{\"Value\":9.00,\"Units\":\"km/h\"},\"Surface Pressure\":{\"Value\":1000.90,\"Units\":\"hPa\"},\"Relative Humidity\":{\"Value\":19,\"Units\":\"%\"},\"Precipitation\":{\"Value\":0.00,\"Units\":\"mm\"}}]\nRecord successfully created: {name: -OZXtVY1YUZcvv0KQVZS}\n^C\nmicrcx@micrcx-desktop:~/toit/rest$ \n```\n\n## Movie\n\n[fb2.webm](https://github.com/user-attachments/assets/a17a1234-2e93-427e-acc1-7f0cf33a9cc4)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmk590901%2Ftoit-rest-api-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmk590901%2Ftoit-rest-api-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmk590901%2Ftoit-rest-api-db/lists"}