summaryrefslogtreecommitdiffhomepage
path: root/cloud/core/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'cloud/core/src/util')
-rw-r--r--cloud/core/src/util/resource.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/cloud/core/src/util/resource.ts b/cloud/core/src/util/resource.ts
new file mode 100644
index 000000000..1543145dc
--- /dev/null
+++ b/cloud/core/src/util/resource.ts
@@ -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>;