Skip to content

Commit

Permalink
🐛 Change the way of fetching sst env from dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Feb 21, 2025
1 parent c0f1607 commit 0a62932
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"package.json",
"sw.js",
"bundle.js",
"sst-env.d.ts"
"sst-env.d.ts",
".react-router/**"
]
},
"organizeImports": {
Expand Down
25 changes: 14 additions & 11 deletions packages/dashboard/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { NextConfig } from "next";
import { pick } from "radash";
import { Resource } from "sst";

const DEBUG = false;
Expand All @@ -11,16 +10,20 @@ const wantedFromConfig = [
"SESSION_ENCRYPTION_KEY",
"MONGODB_BUSINESS_URI",
"FUNDING_ON_RAMP_URL",
] as (keyof Resource)[];

// The Resource.XXX can be an object with { value: string }, needed to upper up the value
const envFromSstConfig = Object.fromEntries(
Object.entries(pick(Resource, wantedFromConfig)).map(([key, value]) => [
key,
"value" in value ? value.value : "",
])
);
] as string[];

// Get the env variables from the Resource
const envFromSst: Record<string, string> = {};
for (const key of wantedFromConfig) {
// If the key is not in the Resource, skip
if (!(key in Resource)) continue;
// Get the value from the Resource
const value = Resource[key as keyof typeof Resource];
// If the value is an object with a value property, add it to the envFromSst object
if (value && typeof value === "object" && "value" in value) {
envFromSst[key] = value.value;
}
}
const isDistant = ["prod", "dev"].includes(Resource.App.stage);

const nextConfig: NextConfig = {
Expand All @@ -41,7 +44,7 @@ const nextConfig: NextConfig = {
INDEXER_URL: process.env.INDEXER_URL,
DEBUG: JSON.stringify(DEBUG),
// Secrets from sst
...envFromSstConfig,
...envFromSst,
},
transpilePackages: ["lucide-react", "@frak-labs/app-essentials"],
compiler: {
Expand Down

0 comments on commit 0a62932

Please sign in to comment.