fix(imaging): support .hab assets, cache avatars/badges, harden routes
The hotel moved from .nitro to .hab bundles, so the imager must treat .hab like .nitro and the public avatar endpoints must accept the figure strings the client sends (including extra trailing segments such as `.0`, which the old FIGURE_RE rejected with a 400). - imager-upstream: relax FIGURE_RE, extend parseAvatarQuery test coverage - api/imaging/avatar + /imaging: shared validation, placeholder and ETag/304 - api/imaging/badge: single-flight upstream fetch and conditional responses - imager-http/imager-png: strong ETag helpers and APNG passthrough guard - csp + next/image: unoptimized external images, tightened CSP - deps: override postcss-selector-parser to ^7.1.6 - also fold in the pending drizzle draft snapshot and stray test cleanup
This commit is contained in:
1 parent
56676effc3
commit
f3407ebfdf
29 files changed
+15134
-93
No files matched your search
@@ -108,6 +108,28 @@ it("serves a previously rendered avatar from the disk cache without re-fetching"
|
||||
expect(fetcher.mock.calls.length).toBe(callsAfterFirst);
|
||||
});
|
||||
|
||||
it("revalidates a cached avatar with a 304 when the client already has it", async () => {
|
||||
const fetcher = vi.fn(
|
||||
async () =>
|
||||
new Response(new Uint8Array([1, 2, 3]), {
|
||||
headers: { "content-type": "image/png" },
|
||||
}),
|
||||
);
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
vi.stubEnv("IMAGER_URL", "https://etag.test/avatarimage");
|
||||
const url = "https://hotel.test/api/imaging/avatar?figure=hd-77-1";
|
||||
const first = await GET(new NextRequest(url));
|
||||
const etag = first.headers.get("etag");
|
||||
expect(etag).toBeTruthy();
|
||||
|
||||
const second = await GET(
|
||||
new NextRequest(url, { headers: { "if-none-match": etag } }),
|
||||
);
|
||||
expect(second.status).toBe(304);
|
||||
expect(second.headers.get("etag")).toBe(etag);
|
||||
expect(second.headers.get("x-imager-source")).toBe("cache");
|
||||
});
|
||||
|
||||
it("serves a graceful silhouette instead of a broken image when every upstream is down", async () => {
|
||||
const fetcher = vi.fn(
|
||||
async (_input: string | URL) =>
|
||||
|
||||
Reference in new issue
Block a user