summaryrefslogtreecommitdiffhomepage
path: root/cloud/core/src/util/resource.ts
blob: 1543145dcd4d186d17ebb63b49e5df9b9249a5cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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>;