bini-env 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts DELETED
@@ -1,79 +0,0 @@
1
- import { Plugin } from 'vite';
2
- export { Plugin } from 'vite';
3
-
4
- interface BiniEnvPluginOptions {
5
- /**
6
- * Enable/disable the plugin
7
- * @default true
8
- */
9
- readonly enabled?: boolean;
10
- /**
11
- * Remove Vite's default header
12
- * @default true
13
- */
14
- readonly clearViteHeader?: boolean;
15
- /**
16
- * Custom logo/text to display
17
- * @default 'ß'
18
- */
19
- readonly logo?: string;
20
- /**
21
- * Override the env var prefix exposed to client code.
22
- * Defaults to 'BINI_' — so BINI_MY_VAR is accessible via import.meta.env.BINI_MY_VAR
23
- * Set to 'VITE_' to keep Vite's default behaviour.
24
- * @default 'BINI_'
25
- */
26
- readonly envPrefix?: string;
27
- }
28
- interface DetectedEnvFile {
29
- readonly name: string;
30
- readonly path: string;
31
- }
32
- /**
33
- * Read an environment variable in any runtime.
34
- *
35
- * Priority order:
36
- * 1. Deno.env — Netlify edge functions / Deno runtime
37
- * 2. process.env — Node.js / Bun / bini-server
38
- * 3. import.meta.env — Vite client (BINI_-prefixed vars)
39
- *
40
- * Usage in API routes:
41
- * import { getEnv } from 'bini-env';
42
- * const smtpUser = getEnv('SMTP_USER');
43
- */
44
- declare function getEnv(key: string): string | undefined;
45
- /**
46
- * Read an environment variable and throw if it's missing or empty.
47
- * Use this for required secrets so you get a clear error at startup
48
- * instead of a cryptic crash later.
49
- *
50
- * Usage:
51
- * const smtpPass = requireEnv('SMTP_PASS');
52
- */
53
- declare function requireEnv(key: string): string;
54
- /**
55
- * Auto-load .env into process.env for Node.js API route contexts.
56
- *
57
- * Behaviour by environment:
58
- * - Deno (edge functions) → no-op, Deno/Netlify injects env natively
59
- * - NODE_ENV=production → no-op, host injects env vars automatically
60
- * - Node.js dev → loads .env via dotenv (dynamic import, safe for bundlers)
61
- *
62
- * Called automatically by bini-env Vite plugin. You should not need to call this manually.
63
- */
64
- declare function loadEnv(projectRoot?: string): Promise<void>;
65
- /**
66
- * Detect which .env files exist in the project root, in Vite's priority order.
67
- */
68
- declare function detectEnvFiles(projectRoot?: string): DetectedEnvFile[];
69
- /**
70
- * Bini.js Vite plugin.
71
- *
72
- * What it does:
73
- * - Sets envPrefix to 'BINI_' so client code uses import.meta.env.BINI_MY_VAR
74
- * - Auto-loads .env for API routes in dev via loadEnv()
75
- * - Replaces Vite's startup output with the Bini.js branded header
76
- */
77
- declare function biniEnv(options?: Readonly<BiniEnvPluginOptions>): Plugin;
78
-
79
- export { type BiniEnvPluginOptions, type DetectedEnvFile, biniEnv, detectEnvFiles, getEnv, loadEnv, requireEnv };