Skip to content

jessekelly881/effect-supabase

Repository files navigation

effect-supabase

An Effect wrapper for the Supabase sdk.

Database queries

Queries are inspired by and hope to be as complete as those provided by sqlfx.

import { Supabase } from "effect-supabase";
import { Schema } from "@effect/schema";

const EventId = Schema.Int.pipe(Schema.brand(""EventId));

const Event = Schema.Struct({
  starts: Schema.Date
});

export const getEventById = (id: EventId) =>
  Effect.flatMap(Supabase, (sb) =>
    Supabase.resolver("getEventById", {
        result: Event,
        request: EventId,
 run: (ids) => sb.client.from("events").select("*").in("id", ids)
    }).execute(id)
  ).pipe(Effect.withSpan("getEventById", { attributes: { id } }));

Functions

Simplified edge functions using Effect and HatTip.

import { Effect } from "npm:effect";
import { createServeHandler } from "npm:@hattip/adapter-deno";
import { HttpServer } from "npm:@effect/platform";

const handler = HttpServer.app.toWebHandler(
  Effect.map(HttpServer.request.ServerRequest, (req: Request) =>
   HttpServer.response.text(req.url),
  )
 );

Deno.serve(
 createServeHandler(({ request }: { request: Request }) => handler(request)),
);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published