All files / src/storage create-avatar-store.ts

71.42% Statements 5/7
50% Branches 1/2
100% Functions 1/1
71.42% Lines 5/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 171x                   1x 39x 39x 39x      
import type { AppConfig } from "../config.js";
import type { ObjectStore } from "./object-store.js";
import { createR2Client } from "./r2-client.js";
import { R2ObjectStore } from "./r2-object-store.js";
 
/**
 * Хранилище аватаров — тот же R2-бакет, что и GPX (префикс задаётся ключами `avatars/...`).
 * `null`, если R2 не сконфигурирован (например, локальный dev на диске) — загрузка аватара
 * вернёт 503.
 */
export function createAvatarStore(config: AppConfig): ObjectStore | null {
  if (!config.gpxR2) {
    return null;
  }
  return new R2ObjectStore(createR2Client(config.gpxR2), config.gpxR2.bucket);
}