[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116545":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":12,"contributorsCount":12,"subscribersCount":12,"size":12,"stars1d":12,"stars7d":12,"stars30d":12,"stars90d":12,"forks30d":12,"starsTrendScore":12,"compositeScore":14,"rankGlobal":9,"rankLanguage":9,"license":15,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":18,"hasPages":16,"topics":19,"createdAt":9,"pushedAt":20,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":12,"starSnapshotCount":12,"syncStatus":24,"lastSyncTime":25,"discoverSource":26},116545,"ZipLink-By-Shubham","shubhamgtm\u002FZipLink-By-Shubham","shubhamgtm","Self-hosted URL shortener with QR codes, click tracking, expiring links and password protection. No database needed. Shorten. Share. Track.",null,"JavaScript",46,0,3,40,"MIT License",false,"main",true,[],"2026-11-17 12:53:10","2026-11-23 15:36:06","# ZipLink\n\n**Shorten. Share. Track.**\n\nZipLink is a self-hosted URL shortener built with Node.js and Express. It stores everything in plain JSON files, so there is no database to install or manage. Sign in to a clean dark dashboard, create short links, share them with QR codes, and watch real click analytics come in.\n\nCreated by **Shubham Gautam Upadhyaya** ([@ShubhamGtm_](https:\u002F\u002Fgithub.com\u002Fshubhamgtm)) and released under the MIT License.\n\n## Features\n\n- Shorten any `http:\u002F\u002F` or `https:\u002F\u002F` URL\n- Random short codes or your own custom alias\n- QR code for every link, downloadable as PNG or SVG\n- Click tracking per link, plus a dashboard with totals and analytics\n- Creation date for every link\n- Optional expiration date and time\n- Optional password protection per link (hashed with bcrypt)\n- One-click copy for short links\n- Search, filter, sort and delete links\n- Secure admin login, rate limiting and input validation\n- No database: data lives in `data\u002F` as JSON files\n- Responsive dark interface for phone, tablet and desktop\n\n## Requirements\n\n- Node.js 18 or newer\n- npm (included with Node.js)\n\n## Quick start\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FShubhamGtm_\u002Fziplink.git\ncd ziplink\nnpm install\nnpm run setup\nnpm start\n```\n\nOpen \u003Chttp:\u002F\u002Flocalhost:3000> and sign in with the username and password you chose during setup.\n\n`npm run setup` asks for an admin username and password, then writes a `.env` file containing the bcrypt hash of your password and a freshly generated session secret. Your plain password is never stored.\n\n### Manual setup\n\nIf you prefer to configure things by hand:\n\n```bash\ncp .env.example .env\nnpm run hash -- \"your-strong-password\"\nnpm run secret\n```\n\nCopy the line printed by `npm run hash` (it starts with `ADMIN_PASSWORD_HASH=`) into `.env`, and paste the output of `npm run secret` after `SESSION_SECRET=`. Keep the single quotes around the hash, because bcrypt hashes contain `$` characters.\n\n## Configuration\n\nAll settings come from environment variables, normally set in `.env`.\n\n| Variable | Required | Default | Description |\n| --- | --- | --- | --- |\n| `ADMIN_PASSWORD_HASH` | Yes | none | bcrypt hash of the admin password. Create it with `npm run hash`. |\n| `SESSION_SECRET` | Yes | none | Random string of at least 32 characters used to sign session cookies. Create it with `npm run secret`. |\n| `ADMIN_USERNAME` | No | `admin` | Admin username. |\n| `PORT` | No | `3000` | Port to listen on. |\n| `HOST` | No | `127.0.0.1` | Interface to bind to. Use `0.0.0.0` to allow other devices on your network. |\n| `BASE_URL` | No | request address | Public address used in short links and QR codes, for example `https:\u002F\u002Fzip.example.com`. No trailing path. |\n| `SESSION_HOURS` | No | `12` | How long an admin session stays valid. |\n| `TRUST_PROXY` | No | off | Number of reverse proxies in front of ZipLink, for example `1`. Needed for correct client IPs behind a proxy. |\n\nZipLink refuses to start if a required value is missing or malformed, and tells you what to fix.\n\n## Using ZipLink\n\n1. Paste a long URL and press **Shorten**. If you leave out `https:\u002F\u002F`, ZipLink adds it.\n2. Open **Options** to set a custom alias, an expiration date and time, or a password.\n3. Copy the new link with **Copy link**, or open its **QR code** to scan or download it.\n4. Track results on the dashboard: total links, total clicks, active links, password-protected links, a 14-day click chart, top links, referrers and devices.\n5. Use the search box, status filter and sort menu to find links in the **Recent links** table. **Delete** removes a link and its click history after confirmation.\n\nShort links work for anyone, but creating and managing them requires the admin login.\n\n### Behavior worth knowing\n\n- **Expired links** show an \"expired\" page (HTTP 410) and no longer redirect. They stay in the table so you can review their stats, and they are counted under \"Expired\" instead of \"Active\".\n- **Password-protected links** show an unlock page. The visitor is redirected only after entering the correct password, and only then is a click counted. Wrong guesses are rate limited.\n- **Aliases** are 3 to 32 characters: letters, numbers, `-` and `_`. They are unique regardless of letter case, and a few names such as `api` and `admin` are reserved.\n- **Self-referencing links** (a URL that points back at your own ZipLink) are rejected to prevent redirect loops.\n\n## How analytics work\n\nEvery analytic comes from real redirects. Nothing is simulated.\n\nFor each click ZipLink records the time, the referring site (or \"Direct\"), and a device type guessed from the user agent (Desktop, Mobile, Tablet or Other). It does **not** store IP addresses.\n\nRequests that are not real visits are skipped: `HEAD` requests, browser prefetches, and well-known crawlers and link-preview bots. The 14-day chart uses your browser's time zone for day boundaries.\n\n## Data storage\n\n| File | Contents |\n| --- | --- |\n| `data\u002Flinks.json` | Every link: code, destination, creation date, expiration, and the bcrypt hash of its password if it has one. |\n| `data\u002Fclicks.jsonl` | One JSON object per line for each recorded click. |\n\nFiles are created automatically on first use. Link changes are written atomically (temporary file, then rename), and clicks are appended. If `links.json` is damaged, ZipLink stops with an error instead of overwriting it.\n\nTo back up ZipLink, copy the `data\u002F` folder. Stop the server before editing these files by hand.\n\n## API\n\nThe dashboard uses a small JSON API. All endpoints except `\u002Fapi\u002Fsession` and `\u002Fapi\u002Flogin` need the session cookie that login sets. State-changing requests must be sent as `application\u002Fjson`.\n\n| Method and path | Purpose |\n| --- | --- |\n| `GET \u002Fapi\u002Fsession` | Whether you are signed in. |\n| `POST \u002Fapi\u002Flogin` | Body `{ \"username\", \"password\" }`. Sets the session cookie. |\n| `POST \u002Fapi\u002Flogout` | Ends the session. Send `{}` as the body. |\n| `GET \u002Fapi\u002Flinks` | All links, newest first, with click counts. |\n| `POST \u002Fapi\u002Flinks` | Body `{ \"url\", \"alias\"?, \"expiresAt\"?, \"password\"? }`. `expiresAt` is an ISO 8601 date in the future. |\n| `DELETE \u002Fapi\u002Flinks\u002F:code` | Delete a link and its clicks. |\n| `GET \u002Fapi\u002Flinks\u002F:code\u002Fqr` | QR code image. Query: `format=png\\|svg`, `size=128..1024`, `download=1`. |\n| `GET \u002Fapi\u002Fstats` | Totals, 14-day series, top links, referrers and devices. Query: `offset` (minutes from UTC). |\n| `GET \u002Fhealth` | Returns `{ \"status\": \"ok\" }`. |\n\nExample with curl:\n\n```bash\ncurl -c cookies.txt -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"username\":\"admin\",\"password\":\"your-password\"}' \\\n  http:\u002F\u002Flocalhost:3000\u002Fapi\u002Flogin\n\ncurl -b cookies.txt -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"url\":\"https:\u002F\u002Fexample.com\u002Fsome\u002Flong\u002Fpath\",\"alias\":\"demo\"}' \\\n  http:\u002F\u002Flocalhost:3000\u002Fapi\u002Flinks\n```\n\n## Security\n\n- Admin password is stored only as a bcrypt hash (12 rounds). Link passwords are bcrypt hashes too (10 rounds).\n- Sessions use a random ID signed with HMAC-SHA256 in an `HttpOnly`, `SameSite=Strict` cookie, marked `Secure` over HTTPS. Sessions live in memory, so restarting the server signs everyone out.\n- Rate limits: failed logins (10 per 15 minutes per IP), wrong link passwords (10 per 15 minutes per IP), link creation (30 per minute), and a general cap on API and redirect traffic.\n- Input is validated on the server: URL scheme and length, alias format, future-only expiry dates, password length, and a 10 KB limit on request bodies.\n- State-changing requests are checked for a matching `Origin` and a JSON content type.\n- Helmet sets a strict Content Security Policy and other security headers. The interface loads no external scripts, fonts or images.\n- Secrets live in `.env`, which is ignored by git.\n\nUse HTTPS in production. See [SECURITY.md](SECURITY.md) for the deployment checklist and how to report a vulnerability.\n\nThe password library is [`bcryptjs`](https:\u002F\u002Fgithub.com\u002FdcodeIO\u002Fbcrypt.js), a pure JavaScript implementation of bcrypt. Its hashes are interchangeable with native bcrypt, and it installs on every platform without a compiler.\n\n## Deploying\n\nZipLink is a single Node process, so any host that runs Node works. A typical setup:\n\n1. Run it with a process manager such as systemd or PM2, using `npm start`.\n2. Put a reverse proxy with HTTPS in front of it.\n3. In `.env`, set `BASE_URL=https:\u002F\u002Fyour.domain` and `TRUST_PROXY=1`.\n\nMinimal nginx location block:\n\n```nginx\nlocation \u002F {\n    proxy_pass http:\u002F\u002F127.0.0.1:3000;\n    proxy_set_header Host $host;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n}\n```\n\nRun a single instance. Sessions are held in memory and data is stored in local files, so ZipLink is not designed to be load balanced across several processes. It suits personal and small-team use rather than very high traffic.\n\nTo reach it from another device on your network, set `HOST=0.0.0.0` and open the machine's address, for example `http:\u002F\u002F192.168.1.20:3000`.\n\n## Project structure\n\n```\nziplink\u002F\n├── server.js          Express app, JSON storage, auth, API, setup commands\n├── package.json\n├── .env.example       Template for configuration\n├── .gitignore\n├── public\u002F\n│   ├── index.html     Login and dashboard\n│   ├── styles.css     Dark theme\n│   └── app.js         Dashboard logic\n├── data\u002F              links.json and clicks.jsonl (created at runtime)\n├── README.md\n├── LICENSE\n├── CONTRIBUTING.md\n├── CHANGELOG.md\n└── SECURITY.md\n```\n\n## npm scripts\n\n| Script | What it does |\n| --- | --- |\n| `npm start` | Start the server. |\n| `npm run dev` | Start the server and restart on file changes. |\n| `npm run setup` | Create `.env` interactively. |\n| `npm run hash -- \"password\"` | Print an `ADMIN_PASSWORD_HASH` line for a password. |\n| `npm run secret` | Print a random session secret. |\n\n## Troubleshooting\n\n- **\"ZipLink cannot start\"**: the message lists exactly which `.env` values are missing or invalid. Run `npm run setup` to regenerate them.\n- **Port already in use**: change `PORT` in `.env`.\n- **Forgot the admin password**: run `npm run setup` again, or generate a new hash with `npm run hash` and replace `ADMIN_PASSWORD_HASH` in `.env`. Existing links are not affected.\n- **Too many sign-in attempts**: wait 15 minutes, or restart the server to clear the counter.\n- **Short links show `localhost`**: set `BASE_URL` to your public address.\n- **Copy button does nothing on a LAN address**: browsers restrict the clipboard API on plain HTTP. ZipLink falls back to a legacy method, but HTTPS is the reliable fix.\n\n## Contributing\n\nContributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.\n\n## License\n\nMIT License. Copyright (c) 2026 Shubham Gautam Upadhyaya. See [LICENSE](LICENSE).\n","ZipLink 是一个轻量级自托管 URL 缩短服务，无需数据库依赖，所有数据以 JSON 文件形式本地存储。核心功能包括生成带自定义别名或随机码的短链接、为每个链接生成可下载的 PNG\u002FSVG 格式 QR 码、按链接粒度统计点击量、设置过期时间与密码保护（bcrypt 加密）、提供带实时分析的暗色管理后台，以及支持搜索、过滤与批量删除。适用于个人开发者、小型团队或内网环境下的私有链接分发与效果追踪场景，兼顾安全性、易部署性与低运维成本。",2,"2026-11-24 04:53:48","CREATED_QUERY"]