wip: cloud
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { defineConfig } from "drizzle-kit"
|
||||
import { Resource } from "sst"
|
||||
import { Resource } from "./src/util/resource"
|
||||
|
||||
export default defineConfig({
|
||||
out: "./migrations/",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Resource } from "sst"
|
||||
import { Stripe } from "stripe"
|
||||
import { Database, eq, sql } from "./drizzle"
|
||||
import { BillingTable, PaymentTable, UsageTable } from "./schema/billing.sql"
|
||||
@@ -8,6 +7,7 @@ import { z } from "zod"
|
||||
import { Identifier } from "./identifier"
|
||||
import { centsToMicroCents } from "./util/price"
|
||||
import { User } from "./user"
|
||||
import { Resource } from "./util/resource"
|
||||
|
||||
export namespace Billing {
|
||||
export const stripe = () =>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { drizzle } from "drizzle-orm/postgres-js"
|
||||
import { Resource } from "sst"
|
||||
import { Resource } from "../util/resource"
|
||||
export * from "drizzle-orm"
|
||||
import postgres from "postgres"
|
||||
|
||||
|
||||
14
cloud/core/src/util/resource.ts
Normal file
14
cloud/core/src/util/resource.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { env } from "cloudflare:workers";
|
||||
|
||||
export const Resource = new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_target, prop: string) {
|
||||
if (prop in env) {
|
||||
const value = env[prop];
|
||||
return typeof value === "string" ? JSON.parse(value) : value;
|
||||
}
|
||||
throw new Error(`"${prop}" is not linked in your sst.config.ts`);
|
||||
},
|
||||
}
|
||||
) as Record<string, any>;
|
||||
Reference in New Issue
Block a user