A Wasm-based serverless URL shortener built with Spin and Astro, deployable to Akamai Functions.
Short links are stored in Spin's (or Akamai Function's) built-in key-value store. Every redirect increments a hit counter. A responsive management UI is included in the box as well.
To compile and run the application locally you need:
spinCLI — the Spin runtime- Rust with the
wasm32-wasip2target:rustup target add wasm32-wasip2
- Node.js >= 22.12.0 (for building the frontend)
For deploying to Akamai Functions you additionally need the aka plugin for spin CLI:
spin plugins install aka --yesCompile both the API and the frontend in one step:
spin buildThis runs cargo build --target wasm32-wasip2 --release in api/ and npm run build in frontend/.
spin upThe application starts on http://localhost:3000.
| What | URL |
|---|---|
| Management UI | http://localhost:3000/app |
| Follow a short link | http://localhost:3000/:short |
| REST API | http://localhost:3000/_api/links |
Open http://localhost:3000, and you will be redirected to the UI automatically.
Navigate to http://localhost:3000/app to open the management dashboard. From there you can:
- Add a new short link by entering a short code and a destination URL
- Check availability of a short code in real time as you type
- Edit the destination URL of any existing link
- Delete a link with an inline confirmation prompt
- See hit counts for every link
All API routes are prefixed with /_api/.
| Method | Path | Description |
|---|---|---|
GET |
/_api/links |
List all short links |
GET |
/_api/links/:short/available |
Check whether a short code is available |
POST |
/_api/links |
Create a new short link |
PUT |
/_api/links/:short |
Update the destination URL of an existing link |
DELETE |
/_api/links/:short |
Delete a short link |
GET |
/:short |
Redirect to the destination URL (increments hit count) |
curl -iX POST http://localhost:3000/_api/links \
-H 'content-type: application/json' \
-d '{"short": "web", "url": "https://akamai.com"}'Returns 201 Created on success, 400 Bad Request if the short code already exists.
# Check if web is available
curl http://localhost:3000/_api/links/web/available{ "available": false }curl http://localhost:3000/_api/links[
{ "short": "web", "url": "https://akamai.com", "hits": 42 },
{ "short": "docs", "url": "https://spinframework.dev", "hits": 7 }
]curl -iX PUT http://localhost:3000/_api/links/web \
-H 'content-type: application/json' \
-d '{"url": "https://www.akamai.com"}'Returns 204 No Content on success.
curl -iX DELETE http://localhost:3000/_api/links/webReturns 204 No Content on success.
curl -i http://localhost:3000/webReturns a 301 Moved Permanently redirect to the destination URL.
# Authenticate against Akamai Functions
spin aka login
#Deploy the application to your Akamai Functions account
spin aka deployAfter deployment the same routes are available at your assigned Akamai Functions hostname.