MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / validateEnv

Function validateEnv

src/instrumentation.ts:7–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5}
6
7function validateEnv() {
8 const required: [string, string][] = [];
9 const optional: [string, string][] = [
10 ["AI_API_KEY", "AI features (news matching, sentiment)"],
11 ["NEWS_API_KEY", "News sync"],
12 ["POLY_BUILDER_API_KEY", "CLOB trading"],
13 ["POLY_BUILDER_SECRET", "CLOB trading"],
14 ["POLY_BUILDER_PASSPHRASE", "CLOB trading"],
15 ["POLYWORLD_ADMIN_KEY", "Admin endpoints"],
16 ];
17 const missing: string[] = [];
18 for (const [key, label] of required) {
19 if (!process.env[key]) missing.push(` ${key} — ${label}`);
20 }
21 if (missing.length > 0) {
22 throw new Error(
23 `[PolyWorld] Missing required environment variables:\n${missing.join("\n")}\n\nCopy .env.example to .env.local and fill in the values.`,
24 );
25 }
26 const warnings: string[] = [];
27 for (const [key, label] of optional) {
28 if (!process.env[key]) warnings.push(` ${key} — ${label} (disabled)`);
29 }
30 if (warnings.length > 0) {
31 console.warn(`[PolyWorld] Optional env vars not set:\n${warnings.join("\n")}`);
32 }
33}
34
35export async function register() {
36 if (process.env.NEXT_RUNTIME === "nodejs") {

Callers 1

registerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected