diff options
| author | Dax Raad <[email protected]> | 2025-08-20 16:52:43 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-08-20 17:01:18 -0400 |
| commit | 522bed6b7dabd09328b3c8aae90b06ab06344623 (patch) | |
| tree | 905dca3e2b3fb4e765d03f2ec78e285f19a31155 /cloud/core/src | |
| parent | dda672284c69ad399029316a63677cf49cbc54f3 (diff) | |
| download | opencode-522bed6b7dabd09328b3c8aae90b06ab06344623.tar.gz opencode-522bed6b7dabd09328b3c8aae90b06ab06344623.zip | |
ignore: cloud stuff
Diffstat (limited to 'cloud/core/src')
| -rw-r--r-- | cloud/core/src/actor.ts | 1 | ||||
| -rw-r--r-- | cloud/core/src/drizzle/index.ts | 5 | ||||
| -rw-r--r-- | cloud/core/src/util/memo.ts | 11 |
3 files changed, 14 insertions, 3 deletions
diff --git a/cloud/core/src/actor.ts b/cloud/core/src/actor.ts index beb292bb8..0d13f7216 100644 --- a/cloud/core/src/actor.ts +++ b/cloud/core/src/actor.ts @@ -20,7 +20,6 @@ export namespace Actor { properties: { userID: string workspaceID: string - email: string } } diff --git a/cloud/core/src/drizzle/index.ts b/cloud/core/src/drizzle/index.ts index 76220f2a2..46fe93ac4 100644 --- a/cloud/core/src/drizzle/index.ts +++ b/cloud/core/src/drizzle/index.ts @@ -3,7 +3,7 @@ import { Resource } from "sst" export * from "drizzle-orm" import postgres from "postgres" -function createClient() { +const createClient = memo(() => { const client = postgres({ idle_timeout: 30000, connect_timeout: 30000, @@ -19,12 +19,13 @@ function createClient() { }) return drizzle(client, {}) -} +}) import { PgTransaction, type PgTransactionConfig } from "drizzle-orm/pg-core" import type { ExtractTablesWithRelations } from "drizzle-orm" import type { PostgresJsQueryResultHKT } from "drizzle-orm/postgres-js" import { Context } from "../context" +import { memo } from "../util/memo" export namespace Database { export type Transaction = PgTransaction< diff --git a/cloud/core/src/util/memo.ts b/cloud/core/src/util/memo.ts new file mode 100644 index 000000000..3c84cf1fb --- /dev/null +++ b/cloud/core/src/util/memo.ts @@ -0,0 +1,11 @@ +export function memo<T>(fn: () => T) { + let value: T | undefined + let loaded = false + + return (): T => { + if (loaded) return value as T + loaded = true + value = fn() + return value as T + } +} |
