👉 Demo
This is a simple URL shortener repo, perfect for creating shortened URLs on your subdomain that redirect to other links.
- Custom or Auto-Generated URLs: Choose your own URL slugs or let the app auto-generate them.
- Click Counter: Track the number of clicks for each URL.
- QR Code Generator: Generates SVG QR codes for easy sharing.
- Powered by Astro DB + Turso: Leverages Astro DB for quick, serverless data management.
- Optional Public URL Shortener Interface: Enable a public-facing interface for users to create their own short URLs (can be toggled on or off).
Note: This URL shortener is designed for small-scale use and has not been stress-tested or fully optimized for high traffic. It supports a single admin user defined in the
.env
file and usesnode-jsonwebtoken
for authentication. There is currently no brute-force protection, so use with caution. For added security, consider customizing the admin URL and/or enhancing middleware for your needs.
- Turso CLI for database management. Install it here.
-
Authenticate with Turso
$ turso auth login
-
Create the Database
$ turso db create <my_database_name>
-
Retrieve Database Info
$ turso db show <my_database_name>
Copy the database URL and add it to .env as:
ASTRO_DB_REMOTE_URL=<your_database_url>
-
Generate the Token
$ turso db tokens create <my_database_name>
Add the generated token to .env as:
ASTRO_DB_APP_TOKEN=<your_database_token>
-
Push Database to Production
$ npm run db:push
-
Set Up Environment Variables
USERNAME=AdminUser007 PASSWORD=My-great-p@ssw0rd SECRET_KEY=XozzHgfaassdds!asdmas IS_PUBLIC=1 SHOW_GITHUB=1
IS_PUBLIC will unlock the public frontpage url-shortner.
-
Set Up Environment Variables
$ npm run dev
AtroLinky routes:
- /
- /login
- /admin
By caffeinating your developer, you're not just getting the best out of them; you're also ensuring a cheerful and energetic work environment.😊