A fast, tiny URL shortener API.
- Install Bun dependencies:
bun install
- Start the MySQL database and Redis server:
docker compose up
- Run the database migrations:
bunx tsx src/migrate.ts
- Start the Bun server:
bun run src/server.ts
curl -X POST -H "Content-Type: application/json" -d '{"url": "https://example.com"}' http://localhost:8080
{
"url": "https://example.com",
"alias": "<url-alias>"
}
curl -I http://localhost:8080/<url-alias>
HTTP/1.1 301 Moved Permanently
Location: https://example.com