2026-11-24 22:16:57 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:05:11 +01:00
2026-11-24 22:16:57 +01:00
2026-11-24 22:05:11 +01:00

terncode.dev

A self-hosted personal homepage with a password-protected admin panel. It serves an editable link hub (links, projects, badges), short redirects, an image gallery, downloadable files, visitor analytics and an optional browser/IP "tracer".

Built with Express, TypeScript, EJS, SQLite (TypeORM) and esbuild-generated browser bundles.

Features

  • Editable homepage: bio, links, projects, badges, background, avatar, favicon and a custom font
  • Short links via configurable redirects
  • Image gallery with thumbnails, tags, artists, search, pagination and video support
  • File storage with searchable listings and download pages
  • Access codes with quotas, expiry dates, activation windows and IP limits
  • Traffic analytics, per-IP "stalker" views and a world map
  • Request logging, browser fingerprint collection and IP geolocation
  • PWA web manifest generated from site metadata

Requirements

  • Node.js 18.17+ (or 20.3+/21+) and npm — native dependencies such as sharp need a modern Node release
  • ffmpeg and ffprobe on PATH for video uploads and thumbnails (images work without them)
  • Internet access is needed for IP geolocation via ip-api.com; failures are non-fatal

Getting started

npm ci
cp config.template.json config.json
# edit config.json (set your title, admin credentials and port)
npm run build
npm start

The site listens on the port from config.json; if that value is missing or invalid, PORT is used, otherwise 6961. The admin panel lives at /<admin.url> (/admin by default); open /admin/login and sign in with the credentials from config.json.

config.json, dist/, generated JS, storage/, logs/ and the SQLite database are gitignored, so the first build and a local config are required.

For development, run npm run dev: it performs a full build and then watches TypeScript, browser bundles and the server in parallel.

Configuration

config.json is read once at startup and rewritten by the admin editors. It has no schema validation, so keep it valid JSON. config.template.json is the starting template.

Field Purpose
title, titleShort, description Page title, social/OG metadata and the generated site.webmanifest
bio Array of paragraphs shown on the homepage
links, badges, projects Homepage entries; each can have a name, URL, icon and linkHidden flag
redirects Short URL mappings ({ "code": "/g", "url": "..." }) matched against the request path
stats Secret path segments for the raw log and per-tracer report endpoints
font Custom font metadata; uploaded/removed through the metadata editor
admin.url Mount path of the entire admin router (leading slash optional)
admin.username, admin.password Plain-text login credentials
server.port Listening port (valid range: 1–65535; falls back to PORT, then 6961)
server.trustProxy, sessionSecret, cookieSecret, nodeEnv Reserved placeholders; not currently read by the server

Most of the above can also be managed from the admin dashboard; credentials and server settings must be edited in config.json directly.

Scripts

Command Description
npm run build Clean dist/, compile server TypeScript, bundle browser entry points
npm start Run the compiled server via index.js
npm run dev Build once, then watch server, client bundles and TypeScript with concurrently
npm run dev:server / dev:client / dev:ts Run individual watchers
npm run ts, npm run ts-watch Compile or watch TypeScript only
npm run lint, npm run lint:fix ESLint check / fix
npm test Placeholder; no test suite is configured

Client bundles are discovered automatically from src/client/entries/*.ts and written to public/assets/js/*.js by esbuild.mjs. detailed-analytics.ts is additionally obfuscated.

Layout

src/index.ts            Express app, middleware, static assets, routes
src/config.ts           Config loader and TypeORM data source
src/pages/              Public routers: gallery, storage, tracer
src/pages/admin/        Admin login, editors, analytics, stalker
src/db/                 TypeORM entities
src/client/entries/     Browser bundles built by esbuild
views/                  EJS templates (public, partials, admin)
public/                 Static CSS/images and generated JS
tracer/                 Shipped browser fingerprinting script
logs/                   Daily request and tracer logs (runtime)
storage/                Generated uploads: images, thumbnails, files, icons, fonts, site
database.sqlite         SQLite database (created on first run)

Routes at a glance

  • Public: / (homepage), /gallery, /storage, /boomer, /site.webmanifest
  • Tracer: GET /scripts/:id (script), POST /t/:id/... (fingerprint payload), GET /science (first-interaction beacon)
  • Admin (under /<admin.url>): /login, /dashboard, /analytics, /stalker, /stalker-map, metadata/icon/link/project/badge/redirect editors, gallery/file/artist editors and access-code editor
  • /stats-* endpoints are protected by the secret segments in config.stats

Uploads are stored under storage/, processed with sharp, and backed by database.sqlite; the schema is synchronized automatically at startup.

Security and privacy notes

  • Change the default admin / changeme credentials before exposing the site. Credentials are stored in plain text.
  • Admin sessions are in memory (1-hour TTL) and the session cookie is not signed or secure; restarting the server logs everyone out.
  • Login attempts are rate-limited to five failures per IP per five minutes.
  • The application logs requests, collects browser fingerprints and geolocates visitor IPs; review these features and local laws before public deployment.
  • Client IPs are taken from the cf-connecting-ip header first, so deploy behind a proxy that overwrites that header.
  • stats.* values behave as bearer secrets for raw log endpoints; choose long, random strings.

License

GPL-2.0-only. See LICENSE.

S
Description
My personal website
Readme GPL-2.0
512 KiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 49.2%
EJS 44.5%
CSS 4.7%
JavaScript 1.6%