- root deno.json workspace (nodeModulesDir auto), npm versions registered once in imports, deno.lock; remove pnpm-lock/pnpm-workspace/root package.json; members keep minimal package.json (name/type/exports) - tasks: dev, typecheck (tsc 7.0.2 per member + deno check), lint/fmt (biome, useImportExtensions), test (vitest via deno), check:tokens, build (web + deno compile), ci, db:migrate/reset, gen:types - tsconfig base moved to config/ (no root tsconfig.json); deno types -> types/deno.d.ts; web drops baseUrl - server: Deno.serve entry with graceful shutdown, --role migrate|preflight|probe, WEB_ROOT static SPA hosting; drop @hono/node-server, tsx, esbuild build.mjs - logger: redact child() bindings and serialize err by message/stack; sync stdout destination; tests - relative imports get explicit extensions (sites/mp-sync paths left for follow-up) - crash-recovery tests spawn `deno run -A`; tasks tests use unique per-file schemas - single-container Dockerfile + entrypoint (migrate -> preflight -> api+worker watchdog), docker-compose.yml - docs: README, runbook, ADR-001 superseded, plan §1 validation row Co-Authored-By: Claude Fable 5.1 <[email protected]>
29 lines
943 B
TypeScript
29 lines
943 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { json, testApp } from "./helpers.ts";
|
|
|
|
describe("GET /api/v1/health", () => {
|
|
it("免鉴权返回 ok 信封", async () => {
|
|
const { app } = testApp();
|
|
const res = await app.request("/api/v1/health");
|
|
expect(res.status).toBe(200);
|
|
const body = await json(res);
|
|
expect(body.ok).toBe(true);
|
|
expect(body.data.status).toBe("ok");
|
|
expect(body.data.db).toBe("unknown");
|
|
expect(body.data.role).toBe("all");
|
|
});
|
|
|
|
it("未知路由返回 not_found 信封", async () => {
|
|
const { app } = testApp();
|
|
const res = await app.request("/nope");
|
|
expect(res.status).toBe(404);
|
|
expect((await json(res)).error.code).toBe("not_found");
|
|
});
|
|
|
|
it("OpenAPI 文档包含 health", async () => {
|
|
const { app } = testApp();
|
|
const doc = await json(await app.request("/api/openapi.json"));
|
|
expect(doc.paths["/api/v1/health"]).toBeDefined();
|
|
});
|
|
});
|