@leancodepl/config 9.1.0 → 9.2.1

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.
Files changed (2) hide show
  1. package/README.md +39 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @leancodepl/config - Utility for creating configuration getters that access Vite-injected values in development and environment variables in production.
2
+
3
+ Provides a function to create getters for accessing configuration values prefixed with 'VITE_' from `import.meta.env` during development. In production, it retrieves values directly from environment variables, with support for tools like nginx-base from "leancodepl/tools" for parsing.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @leancodepl/config
9
+ ```
10
+
11
+ or
12
+
13
+ ```bash
14
+ yarn add @leancodepl/config
15
+ ```
16
+
17
+ ## API
18
+
19
+ ### `mkGetInjectedConfig()`
20
+
21
+ Creates a getter function for accessing Vite-injected configuration values from environment variables on development, on production it will return the value from the environment variables. You can check "@leancodepl/tools" repository for more information. There's nginx-base defined which parses it out.
22
+
23
+ The keys are automatically prefixed with 'VITE_' when accessing import.meta.env.
24
+
25
+ **Returns:** An object containing the `getInjectedConfig` method.
26
+
27
+ **It's important to not rename `getInjectedConfig` as it's used later as a pattern to search for**
28
+
29
+ ## Usage Examples
30
+
31
+ ### Accessing Configuration Values
32
+
33
+ ```typescript
34
+ import { mkGetInjectedConfig } from "@leancodepl/config";
35
+
36
+ const { getInjectedConfig } = mkGetInjectedConfig<"API_URL" | "API_KEY">();
37
+
38
+ export const const apiUrl = getInjectedConfig("API_URL");
39
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/config",
3
- "version": "9.1.0",
3
+ "version": "9.2.1",
4
4
  "license": "Apache-2.0",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",