Log Worker

󰃭 2025-01-16

So, here’s the deal. I needed a tool for logging my life data in one place, not scattered across different apps where information gets lost. In search of a solution, I decided to approach it like an software engineer: if there’s a problem - I’ll solve it with code.

I have built log-worker which accept data in JSON format and save it in D1. And after, it provides to export data between dates. It’s so KISS solution, but in this project, I used the serverless approach for the first time and was pleased with the results and process.

curl '<HERE_IS_URL>/log' \
  --request POST \
  --header 'Authorization: <HERE_IS_TOKEN>' \
  --header 'Content-Type: application/json' \
  --data '{
    "data": {
      "event": "pomodoro.start",
      "type": "work",
      "duration": "30"
    }
  }'
curl '<HERE_IS_URL>/log?start=2025-01-01&end=2024-01-31' \
  --header 'Authorization: <HERE_IS_TOKEN>'

Above are examples of how you can use the service.

Okay, We have thing to log data and export it than. Come on, how to set up to smooth experience? I suggest using block programming by Apple, which is called Shortcuts. I created a simple shortcut which accepts an input dictionary and sends it as JSON. To demonstrate the solution’s functionality, I have made shortcut to start Pomodoro session and LOG IT.

That’s it. You can come up with your own scenarios to use with this.