🔗 Snapchate Link Shortener Shorten
Posts
Showing posts from September, 2025
- Get link
- X
- Other Apps
/* Simple URL shortener with preview page - Node.js + Express - SQLite for storage Features: - POST /shorten -> { url, title?, image_url?, auto_redirect_seconds? } returns a short URL using BASE_DOMAIN config - GET /:code -> shows a preview page with image + "Open link" button If auto_redirect_seconds is set, page will redirect after that many seconds - GET /admin -> simple listing of links (for testing) Run: 1) npm init -y 2) npm install express sqlite3 body-parser valid-url 3) node simple-url-shortener-with-preview.js Environment variables: - PORT (default 3000) - BASE_DOMAIN (default http://localhost:3000) { db.run(`CREATE TABLE IF NOT EXISTS links ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT UNIQUE, target_url TEXT, title TEXT, image_url TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, auto_redirect_seconds INTEGER )`); }); // --- Helpers --- const alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJK...
- Get link
- X
- Other Apps
/* Simple URL shortener with preview page - Node.js + Express - SQLite for storage Features: - POST /shorten -> { url, title?, image_url?, auto_redirect_seconds? } returns a short URL using BASE_DOMAIN config - GET /:code -> shows a preview page with image + "Open link" button If auto_redirect_seconds is set, page will redirect after that many seconds - GET /admin -> simple listing of links (for testing) Run: 1) npm init -y 2) npm install express sqlite3 body-parser valid-url 3) node simple-url-shortener-with-preview.js Environment variables: - PORT (default 3000) - BASE_DOMAIN (default http://localhost:3000) { db.run(`CREATE TABLE IF NOT EXISTS links ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT UNIQUE, target_url TEXT, title TEXT, image_url TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, auto_redirect_seconds INTEGER )`); }); // --- Helpers --- const alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJK...