chore: migrate to v3 and adopt Doppler for secrets management #3

Open
kamil wants to merge 574 commits from v3-cleanup into main
Showing only changes of commit cabdd3ffdd - Show all commits

View File

@@ -37,10 +37,12 @@ function rewriteHost(presignedUrl: string): string {
/**
* Returns a presigned URL for a chapter markdown file.
* URL is valid for ~15 minutes (set by the scraper).
* The returned URL points to the public MinIO endpoint and can be used
* server-side (in a +page.server.ts load function) to fetch the markdown content.
*
* @param rewrite - if true, rewrites the MinIO host to PUBLIC_MINIO_PUBLIC_URL
* (for browser use). Defaults to false — the server-side load function fetches
* the URL directly from the internal MinIO endpoint.
*/
export async function presignChapter(slug: string, n: number): Promise<string> {
export async function presignChapter(slug: string, n: number, rewrite = false): Promise<string> {
log.debug('minio', 'presigning chapter', { slug, n });
let res: Response;
try {
@@ -56,7 +58,7 @@ export async function presignChapter(slug: string, n: number): Promise<string> {
}
const data = (await res.json()) as { url: string };
log.debug('minio', 'presign chapter ok', { slug, n });
return rewriteHost(data.url);
return rewrite ? rewriteHost(data.url) : data.url;
}
/**