loisaidasam / the-masters-api

The Masters API!
MIT License
10 stars 2 forks source link

Ready for Masters 2021? #9

Open Rossimac opened 3 years ago

Rossimac commented 3 years ago

Hey,

I wonder if http://samsandberg.com/themasters/ will be updated for this year's scoring?

If not, I can look to set up my own API (tried to last year but got severely stuck trying to run any of the files - Windows developer life 😄 , I need to learn...)!

Cheers, Ross.

P.S. here is my site using your example API, if interested https://karlasretirementfund.me P.P.S thank you very much for doing this and hosting it as well!

Rossimac commented 3 years ago

I got it hosted through docker, cheers!

Same issue as last year, with the up/down buttons not being there on day 1, so the JSON parsing needed reverting back to original parser.

loisaidasam commented 3 years ago

Sorry for the delay. I commented in #11 as well. See you next year!

loisaidasam commented 3 years ago

Any chance you want to share some of your Docker-ization code?

Rossimac commented 3 years ago

Sure, it's not pretty! Did it in haste so wasn't thinking about others seeing my workflow 😄 .

I am running a Windows machine, so it was kinda hard to get things like curl, pup and jq to run, despite them all having Windows versions. In the end, I downloaded the Linux versions of each and copied them to a Debian-backed docker container.

I could have set up a cron job within docker but I have more experience with Windows Task Scheduler, so created a .bat file to start the docker run process every minute.

I didn't have a need to keep a history and a pointer to the latest version in a separate file, so I just overwrote the same file every minute. It would be interesting to understand your reasons for this approach and its benefits!

The JSON file would be copied to a shared volume so that IIS could then find it and host it.

Used letsencrypt to get a TLS certificate.

I'll take a look later and try to put something together that's sorta useable by others.

Rossimac commented 2 years ago

Hi Sam,

I never forgot about this request to give more info on the dockerized stuff. Came back to this for 2022 and decided to re-write this in .NET 6.0 and wrap it in a Web API.

Here is my repo: https://github.com/Rossimac/golf-scoreboard

Runnable using docker-compose up and then using Nginx Proxy Manager as a proxy.

Hope it helps!