Skip to content

onsetsoftware/replicache-supabase-edge-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Replicache - Supabase Edge Function

This is a Supabase edge function which acts as a backend for Replicache. It is based on a combination of the various examples in the Replicache repositories.

Features

  • Implementation of the Replicache key:value store using Supabase's Postgres database
  • Endpoints for Replicache push, pull, create-space and space-exists functions
  • Auth tokens are forwarded to the DB for use with Row Level Security if required

Setup

The easiest way to get started is to clone this repo into a local supabase/cli project.

Mutators

The index.ts file imports a mutators object from ../_shared/mutators.ts. Create this file and copy in your mutators from your Replicache client. Recommended directory structure for Supabase functions is found in the supabase edge function docs.

From your Supabase project root, run:

git clone https://github.com/onsetsoftware/replicache-supabase-edge-function.git supabase/functions/replicache

supabase start

# !! make sure your mutators file has been added !!
supabase functions serve replicache

Endpoints

The function exposes 4 endpoints:

  • POST /push?spaceID={spaceID}
  • POST /pull?spaceID={spaceID}
  • POST /create-space?spaceID={spaceID}
  • POST /space-exists?spaceID={spaceID}

For example, in local development a typical URL would look like http://localhost:54321/functions/v1/push?spaceID=123.

About

A Supabase Edge Function for Replicache

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published