윤정민 c94ce69e4f Remove redundant .js extensions from import paths.
- TypeScript 소스 파일 내 모든 import 구문에서 불필요한 `.js` 확장자를 제거하여 모듈 참조 방식을 표준화했습니다.
- 핸들러, 서비스, 리포지토리 및 테스트 코드를 포함한 프로젝트 전반의 import 경로를 일관성 있게 정리했습니다.
2026-05-06 16:17:51 +09:00

22 lines
720 B
TypeScript

import type { Request } from "firebase-functions/https";
import { auth } from "../firebase";
import { HttpError } from "./errors";
export async function requireAdmin(req: Request): Promise<string> {
const header = req.get("authorization") ?? req.get("Authorization");
if (!header || !header.startsWith("Bearer ")) {
throw new HttpError(401, "Missing Bearer token");
}
const token = header.substring(7).trim();
try {
const decoded = await auth.verifyIdToken(token);
if (decoded.admin !== true) {
throw new HttpError(403, "admin claim required");
}
return decoded.uid;
} catch (err) {
if (err instanceof HttpError) throw err;
throw new HttpError(401, "Invalid token");
}
}