CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-supabase--supabase-js

Isomorphic JavaScript client for Supabase providing authentication, database, real-time, storage, and edge functions capabilities.

89

0.95x
Overview
Eval results
Files

task.mdevals/scenario-7/

Media Gallery URL Generator

Build a simple media gallery service that uploads images and generates publicly accessible URLs.

Requirements

Your task is to implement a media gallery service that:

  1. Uploads image files to a public storage bucket named "gallery"
  2. Generates public URLs that allow immediate access to the uploaded images
  3. Retrieves public URLs for multiple images by their file names

All images should be accessible via their public URLs without requiring authentication.

Implementation

@generates

API

/**
 * Uploads an image file to storage and returns its public URL
 *
 * @param fileName - The name to store the file as
 * @param fileData - The file data as a Buffer
 * @returns Object containing the file path and public URL
 */
export async function uploadImage(
  fileName: string,
  fileData: Buffer
): Promise<{ path: string; publicUrl: string }>;

/**
 * Gets public URLs for multiple images in the gallery
 *
 * @param fileNames - Array of file names to get URLs for
 * @returns Array of objects containing file names and their public URLs
 */
export async function getImageUrls(
  fileNames: string[]
): Promise<Array<{ fileName: string; publicUrl: string }>>;

Test Cases

  • Uploading a file "profile.jpg" with sample data returns an object with path "profile.jpg" and a publicUrl string that includes "profile.jpg" @test
  • Calling getImageUrls with ["photo1.jpg", "photo2.jpg"] returns an array with two objects, each containing fileName and publicUrl properties @test
  • The publicUrl returned for an uploaded image is a valid HTTPS URL @test

Dependencies { .dependencies }

@supabase/supabase-js { .dependency }

Provides storage capabilities including file upload and public URL generation.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-supabase--supabase-js

tile.json