initial commit
This commit is contained in:
20
packages/env/package.json
vendored
Normal file
20
packages/env/package.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@code/env",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./web": "./src/web.ts",
|
||||
"./native": "./src/native.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@t3-oss/env-core": "^0.13.11",
|
||||
"dotenv": "catalog:",
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@code/config": "workspace:*",
|
||||
"@types/node": "^22.13.14",
|
||||
"typescript": "^6"
|
||||
}
|
||||
}
|
||||
17
packages/env/src/native.ts
vendored
Normal file
17
packages/env/src/native.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { createEnv } from "@t3-oss/env-core";
|
||||
import { z } from "zod";
|
||||
|
||||
const convexUrlSchema = (exampleHost: string) =>
|
||||
z.url().refine((url) => new URL(url).hostname !== exampleHost, {
|
||||
message: `Replace the ${exampleHost} placeholder before running the app`,
|
||||
});
|
||||
|
||||
export const env = createEnv({
|
||||
clientPrefix: "EXPO_PUBLIC_",
|
||||
client: {
|
||||
EXPO_PUBLIC_CONVEX_URL: convexUrlSchema("example.convex.cloud"),
|
||||
EXPO_PUBLIC_CONVEX_SITE_URL: convexUrlSchema("example.convex.site"),
|
||||
},
|
||||
runtimeEnv: process.env,
|
||||
emptyStringAsUndefined: true,
|
||||
});
|
||||
18
packages/env/src/web.ts
vendored
Normal file
18
packages/env/src/web.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { createEnv } from "@t3-oss/env-core";
|
||||
import { z } from "zod";
|
||||
|
||||
const convexUrlSchema = (exampleHost: string) =>
|
||||
z.url().refine((url) => new URL(url).hostname !== exampleHost, {
|
||||
message: `Replace the ${exampleHost} placeholder before running the app`,
|
||||
});
|
||||
|
||||
export const env = createEnv({
|
||||
clientPrefix: "VITE_",
|
||||
client: {
|
||||
VITE_CONVEX_URL: convexUrlSchema("example.convex.cloud"),
|
||||
VITE_CONVEX_SITE_URL: convexUrlSchema("example.convex.site"),
|
||||
},
|
||||
runtimeEnv: (import.meta as any).env,
|
||||
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
||||
emptyStringAsUndefined: true,
|
||||
});
|
||||
6
packages/env/tsconfig.json
vendored
Normal file
6
packages/env/tsconfig.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "@code/config/tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"strictNullChecks": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user