zodified-config-esm 2.1.0 → 2.1.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 +56 -0
  2. package/package.json +5 -1
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Zodified Config
2
+
3
+ Typesafe config validated by Zod 🎉
4
+
5
+ ## Install
6
+
7
+ You can install `zodified-config-esm` from NPM using your prefered package manage.
8
+
9
+ For npm you can install as follows:
10
+
11
+ ```
12
+ npm i zodified-config-esm
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ To use zodified-config, please follow the 3 steps explained below:
18
+
19
+ ### 1. Defining your schema
20
+ ```ts
21
+ // src/schema.ts
22
+ import z from 'zod';
23
+
24
+ export const configSchema = z.object({
25
+ value: z.string()
26
+ });
27
+
28
+ export type Config = z.infer<typeof configSchema>;
29
+ ```
30
+
31
+ ### 2. Validating your config
32
+
33
+ ```ts
34
+ // src/index.ts
35
+ import config from 'zodified-config-esm'
36
+ import type { Config } from './schema'
37
+
38
+ declare module 'zodified-config-esm' {
39
+ interface ValidatedConfig extends Config {}
40
+ }
41
+
42
+ try {
43
+ zodifiedConfig.validate(invalidSchema);
44
+ } catch (error: unknown) {
45
+ // if you enter here, it means the config is invalid or something else went wrong
46
+ // check the error.message
47
+ }
48
+ ```
49
+
50
+ ### 3. Accessing configuration values
51
+ ```ts
52
+ // file other.ts
53
+ import config from 'zodified-config-esm'
54
+
55
+ config.get('value');
56
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zodified-config-esm",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "description": "Typesafe config validated by Zod",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,6 +13,10 @@
13
13
  "node": ">=14"
14
14
  },
15
15
  "main": "./dist/index.js",
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "provenance": true
19
+ },
16
20
  "files": [
17
21
  "dist"
18
22
  ],