All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 18m6s
- Created src/types.ts with AuthenticatedRequest interface extending Express Request - Replaced (req as any).apiKeyInfo with typed AuthenticatedRequest cast in: - auth.ts, usage.ts, pdfRateLimit.ts middleware - index.ts route handlers (usage/me, admin auth, admin usage, admin cleanup, concurrency) - 4 TDD tests added. 566 tests passing (50 files).
25 lines
1 KiB
TypeScript
25 lines
1 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
|
|
describe("AuthenticatedRequest type", () => {
|
|
it("should be importable from types module", async () => {
|
|
const mod = await import("../src/types.js");
|
|
// Type exists — this is a compile-time check; runtime just verifies module loads
|
|
expect(mod).toBeDefined();
|
|
});
|
|
|
|
it("should allow apiKeyInfo on typed request in auth middleware", async () => {
|
|
// Verify auth middleware compiles without 'as any' cast
|
|
const authMod = await import("../src/middleware/auth.js");
|
|
expect(authMod.authMiddleware).toBeTypeOf("function");
|
|
});
|
|
|
|
it("should allow usage middleware to access apiKeyInfo without any cast", async () => {
|
|
const usageMod = await import("../src/middleware/usage.js");
|
|
expect(usageMod.usageMiddleware).toBeTypeOf("function");
|
|
});
|
|
|
|
it("should allow pdfRateLimit middleware to use AuthenticatedRequest", async () => {
|
|
const mod = await import("../src/middleware/pdfRateLimit.js");
|
|
expect(mod.pdfRateLimitMiddleware).toBeTypeOf("function");
|
|
});
|
|
});
|