Join the discussion on Hacker News!
⚠️ To start using PPORT, simply visit pport.deno.dev and follow the instructions.
PPORT is a small experimental project where I explore the simplest and fastest way to deliver software (specifically CLI utilities) over plain HTTP.
To test this method, I built a lightweight text-based chat application that runs directly in the terminal.
The core language is TypeScript. Usually, language choice for me is a matter of taste (especially for projects like this), but in this case, I specifically chose TypeScript because of Deno.
Deno is a fantastic JavaScript runtime that offers two critical features:
- Import and run scripts directly from URLs.
- Transpile TypeScript on the fly without any additional build steps.
Since I chose Deno, it made perfect sense to deploy PPORT on Deno Deploy. This hosting platform allows almost instant deployment simply by connecting a GitHub repository. Because Deno doesn't rely on Docker, projects on Deno Deploy go live within seconds after a commit/push.
All that is required to distribute this CLI utility is a basic HTTP server
and a standard HTTP client (like curl or irm), which is available on
almost every machine.
The magic happens in server.ts, a script that performs several important
tasks:
- Serves a web page with instructions when accessed from a browser.
- Serves an installer script (
.shfor Unix,.ps1for Windows) if the request comes with aUser-Agentfromcurlorirm. - Serves
.tsfiles (e.g.,source/client.ts) if the request comes with aUser-Agentfrom Deno.
When you run:
curl -fsSL pport.deno.dev | shthe following sequence happens:
- The server detects the
User-Agentfromcurland responds with a shell installer script. - The shell script checks if Deno is installed (and installs it if needed).
- It then runs
deno install, triggering further requests topport.deno.dev. - The server, seeing the
User-Agentfrom Deno, responds by serving the required.tssource files.
Simple as that.
