diff --git a/README.md b/README.md index 658c918..f33d9e7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ and explore the code. Happy coding and may your algorithms be ever efficient! ## CLI You don't have to check out this repository to test my code against your inputs! -Simply run the published cli via JSR. +Simply run the published cli via [JSR](https://jsr.io/). Usage: @@ -32,20 +32,37 @@ cat ./inputs/2.txt | deno run jsr:@aoc/2024 -d 2 > version is out of date. Simply run `deno run -A jsr:@aoc/2024 update` to > update to the latest version. -# SaaS (Solutions as a Service) +## SaaS (Solutions as a Service) -You don't have deno installed and just want to get some solutions for your -puzzle inputs?\ -SaaS is the future and here to save you! +_You don't have deno installed and just want to get some solutions for your +puzzle inputs?_\ +_SaaS_ is the future and here to save you! -// TOOD ... +All solutions are available as an API, powered by +[Deno Deploy](https://deno.com/deploy). -```pswh -irm -method "post" https://aoc-2024.palberg.de/days/2 -Body (gc -raw ./inputs/2.txt) -``` +### _Almost OpenAPI_ ™ Spec: + +Use one of these base urls: +[`https://aoc-2024.palberg.de`](https://aoc-2024.palberg.de/info) or +[`https://aoc-2024.deno.dev`](https://aoc-2024.deno.dev/info). + +- `POST /days/:number`: send your raw input as body to get the results +- `GET /info`: get some nice infos +- `GET /days`: see what days are available + +### Examples -// TODO curl not working yet... +If you have access to `curl` you can adopt the following example for your +usecase: ```bash -curl -X POST -d @./inputs/2.txt https://aoc-2024.palberg.de/days/2 +curl -X POST --data-binary @./inputs/1.txt https://aoc-2024.palberg.de/days/1 +``` + +If you are more of a power (_shell_) user the following example might be a +better starting point for you: + +```pswh +irm -method "post" https://aoc-2024.palberg.de/days/2 -Body (gc -raw ./inputs/2.txt) ``` diff --git a/saas.ts b/saas.ts index 807f527..902f5bc 100644 --- a/saas.ts +++ b/saas.ts @@ -6,6 +6,7 @@ export default { async fetch(req) { const url = new URL(req.url); url.pathname = url.pathname.replace(/\/$/, ""); + console.log(`Request for ${url.pathname}`); if (url.pathname === "/info") { return new Response( @@ -49,7 +50,6 @@ export default { } const num = parseInt(match.pathname.groups.num ?? "", 10); - console.log(`Providing solution for day ${num}`); const day = days.get(num); if (day == null) { return new Response(null, { status: 404 });