taskboard

A Kanban-style task board: Next.js 15 (App Router, server actions, route handlers) + PostgreSQL (pg). Designed for SPanel Smart Deploy (detected as Next.js; it runs the standalone output with node server.js).

Features

  • Board with three columns (To do / In progress / Done); add, move, delete tasks via server actions (work without JS too).
  • REST-ish API routes: GET/POST /api/tasks, PATCH/DELETE /api/tasks/:id.
  • GET /api/health -> JSON {status, version, commit, sourceHash, builtAt, uptimeSeconds, database}; 200 when PG is up, 503 otherwise.
  • Footer shows version, git commit, source hash, build time and server start time, so a redeploy is visible on the page.
  • Migrations run at server start (instrumentation.ts -> lib/migrate.ts): idempotent, transactional, guarded by a Postgres advisory lock, with connection retries (default 30 x 2 s). They are skipped during next build.

Configuration

Variable Default Purpose
DATABASE_URL – (required) postgres://user:pass@host:5432/db. SPanel injects it when a PostgreSQL DB is provisioned.
DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME – Fallback if DATABASE_URL is unset (also PG* names).
DATABASE_SSL false true enables TLS (rejectUnauthorized: false).
DB_CONNECT_RETRIES / DB_CONNECT_RETRY_MS 30 / 2000 How long to wait for the DB at start; then exit 1.
SKIP_MIGRATIONS – 1 disables start-time migrations.
APP_VERSION, GIT_COMMIT package.json / git rev-parse Override what the build records.
PORT, HOSTNAME 3000, 0.0.0.0 Smart Deploy sets PORT=8080, HOSTNAME=0.0.0.0.

Build version display

npm run build runs scripts/write-build-info.mjs first, which writes lib/build-info.json (version, git commit if .git exists, a hash of the source tree, build time). A ZIP deploy has no .git, so the source hash and build time are what change between deploys. The committed file is only a placeholder for next dev/tsc; don't commit the generated one (git checkout lib/build-info.json).

To see a redeploy: bump version in package.json (or edit any file under app/), deploy again, and watch the footer. To demo a bad deploy, see "Breaking a build on purpose" below.

Run locally

npm ci
export DATABASE_URL=postgres://taskboard:secret@127.0.0.1:5432/taskboard
npm run dev                     # http://localhost:3000
# production-like:
npm run build && cd .next/standalone && cp -r ../static .next/static && cp -r ../../public public && PORT=3000 node server.js

Deploy with SPanel Smart Deploy

  1. ZIP (git archive -o taskboard.zip HEAD) or Git deploy. Do not include node_modules/.next.
  2. Provision a PostgreSQL database (requires PostgreSQL Manager on the server) so DATABASE_URL is injected; otherwise set it manually under Environment.
  3. Detected as Next.js, build npm run build, port 3000/8080 via PORT. First start applies migrations (see the log).
  4. Bind a domain, open /api/health and the page; footer shows the build.

Breaking a build on purpose (rollback test)

Add const x: number = "oops"; to lib/tasks.ts (type error fails next build) and redeploy: the old deployment should keep serving; then Rollback/redeploy the previous version.

Caveats

  • No custom server.js in the repo: Smart Deploy only injects output: 'standalone' when there is none (it is also set in next.config.mjs).
  • Migrations are embedded in TypeScript (not .sql files) so they are included in the standalone trace.
  • Uses force-dynamic, so nothing is prerendered against the DB at build time (the build container has no database).
  • Don't ship your own Dockerfile expecting it to be used; Smart Deploy ignores it.
S
Description
No description provided
Readme
56 KiB
Languages
TypeScript 78.5%
JavaScript 12%
CSS 9.5%