@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 51 lines 1.57 KB
Raw
1 import * as Provider from "alchemy/Provider";
2 import * as Layer from "effect/Layer";
3 import { Schema, SchemaProvider } from "./Schema.ts";
4
5 export class Providers extends Provider.ProviderCollection<Providers>()("Drizzle") {}
6
7 export type ProviderRequirements = Layer.Services<ReturnType<typeof providers>>;
8
9 /**
10 * Build-time providers for managing Drizzle schemas as Alchemy resources.
11 * Drizzle.Schema regenerates migration SQL via drizzle-kit's programmatic
12 * API on every deploy when the source schema changes.
13 *
14 * @example
15 * ```typescript
16 * import * as Alchemy from "alchemy";
17 * import * as Cloudflare from "@alchemy.run/cloudflare";
18 * import * as Drizzle from "@alchemy.run/drizzle";
19 * import * as Neon from "@alchemy.run/neon";
20 * import * as Effect from "effect/Effect";
21 * import * as Layer from "effect/Layer";
22 *
23 * export default Alchemy.Stack(
24 * "MyStack",
25 * {
26 * providers: Layer.mergeAll(
27 * Cloudflare.providers(),
28 * Drizzle.providers(),
29 * Neon.providers(),
30 * ),
31 * state: Alchemy.localState(),
32 * },
33 * Effect.gen(function* () {
34 * const schema = yield* Drizzle.Schema("app-schema", {
35 * schema: "./src/schema.ts",
36 * });
37 * const project = yield* Neon.Project("app-db");
38 * const branch = yield* Neon.Branch("app-branch", {
39 * project,
40 * migrationsDir: schema.out,
41 * });
42 * return { branchId: branch.branchId };
43 * }),
44 * );
45 * ```
46 */
47 export const providers = () =>
48 Layer.effect(Providers, Provider.collection([Schema])).pipe(
49 Layer.provide(SchemaProvider()),
50 Layer.orDie,
51 );