Claude opus authored everything to make the user and task work. First iteration

This commit is contained in:
2026-03-07 21:39:10 -05:00
parent 8ab1efcca7
commit 2bee7dce43
25 changed files with 2003 additions and 164 deletions

View File

@@ -19,6 +19,8 @@
#include "api/ota/status.cpp"
#include "api/system/info.cpp"
#include "api/system/reboot.cpp"
#include "api/tasks/unity.cpp"
#include "api/users/unity.cpp"
internal const char *TAG = "HTTP_SERVER";
@@ -170,7 +172,8 @@ internal esp_err_t static_file_handler(httpd_req_t *req)
internal esp_err_t cors_options_handler(httpd_req_t *req)
{
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_set_hdr(req, "Access-Control-Allow-Methods", "GET, POST, OPTIONS");
httpd_resp_set_hdr(req, "Access-Control-Allow-Methods",
"GET, POST, DELETE, OPTIONS");
httpd_resp_set_hdr(req, "Access-Control-Allow-Headers", "Content-Type");
httpd_resp_set_status(req, "204 No Content");
httpd_resp_send(req, NULL, 0);
@@ -216,7 +219,7 @@ internal httpd_handle_t start_webserver(void)
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.uri_match_fn = httpd_uri_match_wildcard;
config.max_uri_handlers = 10; // We have info, reboot, options, and static
config.max_uri_handlers = 20;
httpd_handle_t server = NULL;
ESP_LOGI(TAG, "Starting HTTP Server on port: '%d'", config.server_port);
@@ -238,6 +241,20 @@ internal httpd_handle_t start_webserver(void)
httpd_register_uri_handler(server, &api_ota_firmware_uri);
httpd_register_uri_handler(server, &api_ota_bundle_uri);
// Register todo list API routes
httpd_register_uri_handler(server, &api_users_get_uri);
httpd_register_uri_handler(server, &api_users_post_uri);
httpd_register_uri_handler(server, &api_users_delete_uri);
httpd_register_uri_handler(server, &api_tasks_upcoming_uri);
httpd_register_uri_handler(server, &api_tasks_get_uri);
httpd_register_uri_handler(server, &api_tasks_post_uri);
httpd_register_uri_handler(server, &api_tasks_update_uri);
httpd_register_uri_handler(server, &api_tasks_delete_uri);
// Populate dummy data for development
seed_users();
seed_tasks();
#ifdef CONFIG_CALENDINK_DEPLOY_WEB_PAGES
// Register static file handler last as a catch-all wildcard if deployed
httpd_uri_t static_get_uri = {.uri = "/*",