- Remove unused imports (users, and) from api-tokens model - Fix password_hash destructure lint error in user routes - Fix apiErrorResponse mock pattern in all 12 test files (use instanceof) - Remove stale eslint-disable directives from test files - Add eslint override for tests (no-explicit-any, no-require-imports) - Fix unused vars in settings and tokens tests - Fix unused tokenB in integration test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
20 lines
614 B
TypeScript
20 lines
614 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { requireApiAdmin, apiErrorResponse } from "@/src/lib/api-auth";
|
|
import { listUsers } from "@/src/lib/models/user";
|
|
|
|
function stripPasswordHash(user: Record<string, unknown>) {
|
|
const { password_hash: _, ...rest } = user;
|
|
void _;
|
|
return rest;
|
|
}
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
await requireApiAdmin(request);
|
|
const users = await listUsers();
|
|
return NextResponse.json(users.map(u => stripPasswordHash(u as unknown as Record<string, unknown>)));
|
|
} catch (error) {
|
|
return apiErrorResponse(error);
|
|
}
|
|
}
|