Skip to content

Commit

Permalink
ion resource linking
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Jan 11, 2024
1 parent dad0d3c commit d47ea4e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/warm-singers-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sst": patch
---

ion: resource linking
1 change: 1 addition & 0 deletions packages/sst/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export type { SSTConfig } from "./project.js";
export { Resource } from "./resource.js";
16 changes: 16 additions & 0 deletions packages/sst/src/resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
declare global {
const SST_LINKS: { name: string; value: any }[];
}

const resources = Object.fromEntries(
SST_LINKS.map((item) => [item.name, item.value])
);

export const Resource = new Proxy(resources, {
get(target, prop: string) {
if (!(prop in target)) {
throw new Error(`"${prop}" is not linked`);
}
return target[prop];
},
});
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d47ea4e

Please sign in to comment.