Initial commit: page-manager Next.js app with Coolify deploy support

Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents
for deployment to Coolify: in-container cron scheduler
(scripts/cron-runner.mjs) and disk-based upload storage served via
/api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health
for container health checks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
chaloemphong
2026-11-22 11:52:17 +07:00
commit 9d32552457
155 changed files with 22174 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { createRequire } from "node:module";
import ts from "typescript";
// Exercise the same date helpers used by the server query and client board.
const source = readFileSync(new URL("../src/lib/board.ts", import.meta.url), "utf8");
const compiled = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText;
const exports = {};
new Function("exports", "require", compiled)(exports, createRequire(import.meta.url));
const { bkkDayKey, bkkMidnight, addDays, weekStartOf, parseWeekParam, isDayKey, postBoardDate } = exports;
assert.equal(bkkDayKey(new Date("2026-11-20T17:00:00Z")), "2026-11-21");
assert.equal(bkkMidnight("2026-11-21").toISOString(), "2026-11-20T17:00:00.000Z");
assert.equal(weekStartOf("2026-11-22"), "2026-11-16");
assert.equal(addDays("2026-12-31", 1), "2027-01-01");
assert.equal(addDays("2028-02-28", 1), "2028-02-29");
assert.equal(parseWeekParam("2026-11-21"), "2026-11-16");
for (const day of ["2026-02-29", "2026-13-01", "2026-11-31", "bad", "9999-99-99"]) {
assert.equal(isDayKey(day), false);
assert.equal(parseWeekParam(day), weekStartOf(bkkDayKey(new Date())));
}
assert.equal(isDayKey("2028-02-29"), true);
const plannedAt = new Date("2026-11-21T02:00:00Z");
const scheduledPublishAt = new Date("2026-11-22T02:00:00Z");
const updatedAt = new Date("2026-11-23T02:00:00Z");
assert.equal(postBoardDate({ status: "DRAFT", plannedAt, scheduledPublishAt: null, updatedAt }), plannedAt);
assert.equal(postBoardDate({ status: "SCHEDULED", plannedAt, scheduledPublishAt, updatedAt }), scheduledPublishAt);
assert.equal(postBoardDate({ status: "PUBLISHED", plannedAt, scheduledPublishAt: null, updatedAt }), updatedAt);
assert.equal(postBoardDate({ status: "DRAFT", plannedAt: null, scheduledPublishAt: null, updatedAt }), null);
console.log("Board checks passed: Bangkok boundaries, week navigation, invalid dates, publication precedence.");