2025-08-30 12:58:22 +08:00
|
|
|
import { env } from "cloudflare:workers"
|
2025-11-24 04:21:47 +08:00
|
|
|
export { waitUntil } from "cloudflare:workers"
|
2025-08-30 07:34:56 +08:00
|
|
|
|
|
|
|
|
export const Resource = new Proxy(
|
|
|
|
|
{},
|
|
|
|
|
{
|
|
|
|
|
get(_target, prop: string) {
|
|
|
|
|
if (prop in env) {
|
2025-08-30 12:58:22 +08:00
|
|
|
// @ts-expect-error
|
|
|
|
|
const value = env[prop]
|
|
|
|
|
return typeof value === "string" ? JSON.parse(value) : value
|
2025-09-10 03:47:24 +08:00
|
|
|
} else if (prop === "App") {
|
|
|
|
|
// @ts-expect-error
|
|
|
|
|
return JSON.parse(env.SST_RESOURCE_App)
|
2025-08-30 07:34:56 +08:00
|
|
|
}
|
2025-08-30 12:58:22 +08:00
|
|
|
throw new Error(`"${prop}" is not linked in your sst.config.ts (cloudflare)`)
|
2025-08-30 07:34:56 +08:00
|
|
|
},
|
2025-08-30 12:58:22 +08:00
|
|
|
},
|
|
|
|
|
) as Record<string, any>
|