add: more commits

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-03 16:21:27 +08:00
parent 17326b2c2e
commit 7e964f2432
112 changed files with 9160 additions and 3461 deletions
+22
View File
@@ -0,0 +1,22 @@
// utils/media.util.js
//
// Resolves a displayable <img> src for an asset payload that may carry a
// short-lived stream_token (private/S3 — proxied through the backend) instead
// of a raw file_url. Private assets must never expose their real storage URL
// to the browser — see controllers/admin/assets.controller.js's redactS3Url
// pattern, mirrored for advertisements in controllers/*/advertisements.controller.js.
const API_BASE = (import.meta.env.VITE_API_URL ?? "http://localhost:3024").replace(/\/$/, "");
export function streamUrl(token) {
return token ? `${API_BASE}/client/media/stream/${token}` : null;
}
// asset: { stream_token?, file_url?, thumbnail_url? } — stream_token always
// wins when present (proxied); file_url/thumbnail_url are only ever populated
// here for public/chibisafe assets, which don't need proxying.
export function resolveAssetSrc(asset) {
if (!asset) return null;
if (asset.stream_token) return streamUrl(asset.stream_token);
return asset.thumbnail_url || asset.file_url || null;
}