Remote / foldkit-remote-drizzle

Compose the server

ts
const Data = Remote.define({
  entities: [User, Project],
  queries: [ProjectsByOwner],
  mutations: [RenameProject],
})

const Server = RemoteServer.make({
  entities: [source(User), source(Project)],
  queries: [ProjectsByOwnerSource],
  mutations: [RenameProjectSource],
})

RemoteServer.validate(Data, Server)

const handlers = RemoteServer.handlers(Server, principal)

Every Drizzle Source contributes DrizzleDatabase to the Effect environment. If a server combines Sources requiring different services, make that union explicit in the RemoteServer.make environment rather than hiding a dependency.

Database service

ts
import { databaseLayer } from 'foldkit-remote-drizzle'

const DatabaseLive = databaseLayer(db)

db can be any Drizzle database with the select-builder surface this compiler uses. databaseLayer contains the structural adaptation once, so Sources simply yield DrizzleDatabase.

The package does not import drizzle-orm/effect-postgres or any other driver, so it reads through whichever Drizzle database the application opens: provide it through databaseLayer.