summaryrefslogtreecommitdiffhomepage
path: root/cloud/resource/resource.cloudflare.ts
blob: ad3fbe2a8a864b438ab0954cb54700140bc53d1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { env } from "cloudflare:workers"

export const Resource = new Proxy(
  {},
  {
    get(_target, prop: string) {
      if (prop in env) {
        // @ts-expect-error
        const value = env[prop]
        return typeof value === "string" ? JSON.parse(value) : value
      }
      throw new Error(`"${prop}" is not linked in your sst.config.ts (cloudflare)`)
    },
  },
) as Record<string, any>