Load explorer env from repo root

This commit is contained in:
Codex Bot
2026-03-24 00:59:50 +01:00
parent 58c3259f22
commit e2c6f000c3
4 changed files with 15 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import "dotenv/config"; import "@peya-explorer/shared/load-env";
import { z } from "zod"; import { z } from "zod";
const envSchema = z.object({ const envSchema = z.object({
@@ -12,4 +12,3 @@ const envSchema = z.object({
}); });
export const env = envSchema.parse(process.env); export const env = envSchema.parse(process.env);

View File

@@ -1,4 +1,4 @@
import "dotenv/config"; import "@peya-explorer/shared/load-env";
import { z } from "zod"; import { z } from "zod";
const envSchema = z.object({ const envSchema = z.object({
@@ -13,4 +13,3 @@ const envSchema = z.object({
}); });
export const env = envSchema.parse(process.env); export const env = envSchema.parse(process.env);

View File

@@ -4,9 +4,12 @@
"private": true, "private": true,
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./load-env": "./dist/load-env.js"
},
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json" "build": "tsc -p tsconfig.json"
} }
} }

View File

@@ -0,0 +1,9 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import dotenv from "dotenv";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(__dirname, "../../../");
// Workspace commands run from apps/*, so load the root-level .env explicitly.
dotenv.config({ path: path.join(repoRoot, ".env") });