Advanced URL Shortening, Analytics, & Bio-Link Platform with Stealth Security.
317
Secure Express.js REST API for the Link-Snap URL Platform, optimized and containerized with Node.js Alpine and Tini.
This repository contains the containerized REST API server for the Link-Snap platform. It handles database transactions, short URL redirections, analytics collection, biometric challenges, rate limiting, and administration endpoints.
Key Features Implemented:
/.d/ endpoints) protected by WebAuthn/FIDO2 biometrics, designed to bypass automatic scanners.This container uses a multi-stage Docker build to keep the image secure and lightweight:
| Stage | Purpose | Base Image |
|---|---|---|
| Deps | Installs production NPM packages | node:24-alpine |
| Production | Runs the Express API under unprivileged user | node:24-alpine |
Key Container Optimizations:
tini as ENTRYPOINT to ensure zombie processes are reaped and OS signals (SIGTERM, SIGINT) are handled gracefully.linksnap system user.The backend API requires the following environment variables to run:
| Variable | Description | Required | Default |
|---|---|---|---|
PORT | Local port the container exposes | No | 5000 |
MONGO_URI | MongoDB connection URL | Yes | - |
JWT_ACCESS_SECRET | HS256 secret key for signing short-lived tokens | Yes | - |
JWT_REFRESH_SECRET | HS256 secret key for signing session cookies | Yes | - |
SESSION_SECRET | Cookie session encrypt key | Yes | - |
ENCRYPTION_KEY | Hex encryption key for URL passwords | Yes | - |
REDIS_URL | Redis server URL (TCP) for rate limiting | No | - |
REDIS_PASSWORD | Redis authentication password | No | - |
NODE_ENV | Environment context (production or development) | No | production |
CLIENT_URL | Frontend client origin to permit CORS | Yes | - |
Here is the recommended configuration to bootstrap the entire Link-Snap application (Client, API Server, MongoDB, and local Redis cache) in one command:
version: '3.8'
services:
# Frontend Client
linksnap-frontend:
image: tanaymondal/linksnap-frontend:latest
container_name: linksnap-frontend
ports:
- "80:80"
restart: unless-stopped
depends_on:
- linksnap-backend
# Backend Express API
linksnap-backend:
image: tanaymondal/linksnap-backend:latest
container_name: linksnap-backend
ports:
- "5000:5000"
environment:
- NODE_ENV=production
- PORT=5000
- MONGO_URI=mongodb://linksnap-mongo:27017/linksnap
- JWT_ACCESS_SECRET=your_super_secret_jwt_access_key
- JWT_REFRESH_SECRET=your_super_secret_jwt_refresh_key
- SESSION_SECRET=your_cookie_session_encrypt_secret
- ENCRYPTION_KEY=32_byte_hex_encryption_key_goes_here
- REDIS_URL=redis://default:your_redis_password@linksnap-redis:6379
- CLIENT_URL=http://localhost # Matches frontend URL
depends_on:
- linksnap-mongo
- linksnap-redis
restart: unless-stopped
# Distributed cache (Rate limiting / WebAuthn state)
linksnap-redis:
image: redis:7-alpine
container_name: linksnap-redis
command: redis-server --requirepass your_redis_password
restart: unless-stopped
# Database Engine
linksnap-mongo:
image: mongo:6-jammy
container_name: linksnap-mongo
volumes:
- mongo_data:/data/db
restart: unless-stopped
volumes:
mongo_data:
docker-compose.yml.JWT_ACCESS_SECRET, JWT_REFRESH_SECRET, SESSION_SECRET, and ENCRYPTION_KEY.docker compose up -d
http://localhost.docker pull tanaymondal/linksnap-backend:latest