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:
@@ -0,0 +1,26 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import ts from "typescript";
|
||||
import sharp from "sharp";
|
||||
|
||||
const source = readFileSync(new URL("../src/lib/account-profile.ts", import.meta.url), "utf8");
|
||||
const compiled = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS, esModuleInterop: true } }).outputText;
|
||||
const exports = {};
|
||||
new Function("exports", "require", compiled)(exports, createRequire(import.meta.url));
|
||||
const { accountProfileSchema, prepareAvatar } = exports;
|
||||
assert.deepEqual(accountProfileSchema.parse({ name: " ทดสอบ ", bio: " แนะนำตัว " }), { name: "ทดสอบ", bio: "แนะนำตัว" });
|
||||
for (const input of [{ name: " ", bio: "" }, { name: "a".repeat(101), bio: "" }, { name: "A", bio: "a".repeat(501) }, { name: "A", bio: "", globalRole: "SUPERADMIN" }]) {
|
||||
assert.equal(accountProfileSchema.safeParse(input).success, false);
|
||||
}
|
||||
const png = await sharp({ create: { width: 400, height: 200, channels: 3, background: "blue" } }).png().toBuffer();
|
||||
const avatar = await prepareAvatar(new File([png], "test.png", { type: "image/png" }));
|
||||
const metadata = await sharp(Buffer.from(avatar.split(",")[1], "base64")).metadata();
|
||||
assert.equal(metadata.width, 256);
|
||||
assert.equal(metadata.height, 256);
|
||||
assert.equal(metadata.format, "jpeg");
|
||||
assert.equal(metadata.exif, undefined);
|
||||
await assert.rejects(prepareAvatar(new File(["<svg/>"], "bad.svg", { type: "image/svg+xml" })));
|
||||
await assert.rejects(prepareAvatar(new File(["invalid"], "bad.png", { type: "image/png" })));
|
||||
await assert.rejects(prepareAvatar(new File([new Uint8Array(2 * 1024 * 1024 + 1)], "large.png", { type: "image/png" })));
|
||||
console.log("Account profile checks passed: validation, image decoding, dimensions, metadata removal, rejected files.");
|
||||
Reference in New Issue
Block a user