nuxt-safe-runtime-config 0.0.1 → 0.0.2
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/README.md +12 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
Validate Nuxt runtime config at build time using **Zod**, **Valibot**, **ArkType**, or any Standard Schema compatible library.
|
|
9
9
|
|
|
10
|
-
- [✨ Release Notes](/CHANGELOG.md)
|
|
11
|
-
|
|
12
10
|
## Features
|
|
13
11
|
|
|
14
12
|
- 🔒 Validate runtime config at build time with **Zod**, **Valibot**, **ArkType**, and more
|
|
@@ -37,7 +35,8 @@ export default defineNuxtConfig({
|
|
|
37
35
|
|
|
38
36
|
2. Define your runtime config schema using **Valibot**, **Zod**, **ArkType**, or any other Standard Schema compatible library:
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
<details>
|
|
39
|
+
<summary>With Valibot</summary>
|
|
41
40
|
|
|
42
41
|
```typescript
|
|
43
42
|
import { number, object, optional, string } from 'valibot'
|
|
@@ -53,7 +52,10 @@ const runtimeConfigSchema = object({
|
|
|
53
52
|
})
|
|
54
53
|
```
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
</details>
|
|
56
|
+
|
|
57
|
+
<details>
|
|
58
|
+
<summary>With Zod</summary>
|
|
57
59
|
|
|
58
60
|
```typescript
|
|
59
61
|
import { z } from 'zod'
|
|
@@ -69,7 +71,10 @@ const runtimeConfigSchema = z.object({
|
|
|
69
71
|
})
|
|
70
72
|
```
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
</details>
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary>With ArkType</summary>
|
|
73
78
|
|
|
74
79
|
```typescript
|
|
75
80
|
import { type } from 'arktype'
|
|
@@ -85,6 +90,8 @@ const runtimeConfigSchema = type({
|
|
|
85
90
|
})
|
|
86
91
|
```
|
|
87
92
|
|
|
93
|
+
</details>
|
|
94
|
+
|
|
88
95
|
3. Configure your Nuxt app:
|
|
89
96
|
|
|
90
97
|
```typescript
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -52,7 +52,7 @@ function isStandardSchema(schema) {
|
|
|
52
52
|
return schema && typeof schema === "object" && "~standard" in schema && typeof schema["~standard"] === "object" && typeof schema["~standard"].validate === "function";
|
|
53
53
|
}
|
|
54
54
|
function formatIssue(issue) {
|
|
55
|
-
const path = issue.path ? issue.path.map((p) => p.key
|
|
55
|
+
const path = issue.path ? issue.path.map((p) => p && typeof p === "object" && "key" in p ? p.key : p).join(".") : "root";
|
|
56
56
|
return `${path}: ${issue.message || "Validation error"}`;
|
|
57
57
|
}
|
|
58
58
|
|