Integrating Drizzle DB with Existing DB Client in Effect Layers

I'm trapped again into the effect layers thing... How can I provide to my effect just the drizzle DB? I already have a DB client using libsql (which doesn't have a Effect wrapper), and I'm not using direct SQL queries. How can I provide the existing DB client that I have?
const make = Effect.gen(function* (_) {
  const db = yield* SqliteDrizzle.SqliteDrizzle;
  const validateToken = (token: string) =>
    Effect.gen(function* (_) {
      const result = yield* db
        .select()
        .from(tokensTable)
        .where(eq(tokensTable.token, token));
      const token_ = yield* Array.head(result).pipe(
        Effect.catchAll(InvalidToken.create)
      );

      if (token_.expiresAt < new Date()) {
        return yield* new ExpiredToken();
      }
    });

  return {
    validateToken,
  };
});

const DrizzleLive = SqliteDrizzle.layer.pipe(
  Layer.succeed(SqliteDrizzle.SqliteDrizzle, db)
);
Was this page helpful?