fix: create project-thumbnails bucket in instrumentation.ts (#118)

The thumbnail upload (uploadProjectThumbnail) writes to a
'project-thumbnails' storage bucket, but instrumentation.ts only
bootstrapped the 'avatars' bucket.  This caused:

  Upload failed: Bucket not found

Add the missing bucket creation with matching constraints (public,
10 MB limit, image/png only).  Also refactor the bucket-exists check
to use a Set so it scales cleanly as more buckets are added.

Co-authored-by: Anton Pascal <anton-pascal@users.noreply.github.com>
This commit is contained in:
Anton
2026-02-25 12:22:10 -05:00
committed by GitHub
co-authored by Anton Pascal
parent 157b323c0d
commit 94e5f37983
+11 -2
View File
@@ -10,9 +10,9 @@ export async function register() {
const supabase = createClient(url, key) const supabase = createClient(url, key)
const { data: buckets } = await supabase.storage.listBuckets() const { data: buckets } = await supabase.storage.listBuckets()
const exists = buckets?.some((b) => b.name === 'avatars') const bucketNames = new Set(buckets?.map((b) => b.name))
if (!exists) { if (!bucketNames.has('avatars')) {
await supabase.storage.createBucket('avatars', { await supabase.storage.createBucket('avatars', {
public: true, public: true,
fileSizeLimit: 5 * 1024 * 1024, // 5MB fileSizeLimit: 5 * 1024 * 1024, // 5MB
@@ -20,5 +20,14 @@ export async function register() {
}) })
console.log('Created "avatars" storage bucket') console.log('Created "avatars" storage bucket')
} }
if (!bucketNames.has('project-thumbnails')) {
await supabase.storage.createBucket('project-thumbnails', {
public: true,
fileSizeLimit: 10 * 1024 * 1024, // 10MB (matches uploadProjectThumbnail validation)
allowedMimeTypes: ['image/png'],
})
console.log('Created "project-thumbnails" storage bucket')
}
} }
} }