You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define schemas for type-safe environment variables with Zod, Valibot, or any Standard Schema V1 compliant library. Env vars are passed to the handler's `options` object as `options.env`, not in `options.context` or somewhere else. All default filling, optionals, coercing works as in any other place. Though, in theory you can provide whatever you want in `options.context` including env vars, if you want to match the bahavior of oRPC or something else.
138
+
Define schemas for type-safe environment variables with Zod, Valibot, or any Standard Schema V1 compliant library. Env vars are passed to the handler's `options` object as `options.env`, not in `options.context` or somewhere else. All default filling, optionals, coercing works as in any other place. Though, in theory you can provide whatever you want in `options.context` including env vars, if you want to match the behavior of oRPC or something else.
139
139
140
140
**Important: Providing async schema for env variables is not supported, at least for now.**
Define schemas for type-safe environment variables with Zod, Valibot, or any Standard Schema V1 compliant library. Env vars are passed to the handler's `options` object as `options.env`, not in `options.context` or somewhere else. All default filling, optionals, coercing works as in any other place. Though, in theory you can provide whatever you want in `options.context` including env vars, if you want to match the bahavior of oRPC or something else.
138
+
Define schemas for type-safe environment variables with Zod, Valibot, or any Standard Schema V1 compliant library. Env vars are passed to the handler's `options` object as `options.env`, not in `options.context` or somewhere else. All default filling, optionals, coercing works as in any other place. Though, in theory you can provide whatever you want in `options.context` including env vars, if you want to match the behavior of oRPC or something else.
139
139
140
140
**Important: Providing async schema for env variables is not supported, at least for now.**
Copy file name to clipboardExpand all lines: README.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,11 +150,11 @@ import {
150
150
isZagoraError,
151
151
} from'zagora/errors';
152
152
153
-
import*ZagoraTypesfrom'zagora/types';
154
-
import*zagoraUtilsfrom'zagora/utils';
153
+
import*asZagoraTypesfrom'zagora/types';
154
+
import*aszagoraUtilsfrom'zagora/utils';
155
155
```
156
156
157
-
[Back to top](#table-of-contents)
157
+
[**Back to top**](#table-of-contents)
158
158
159
159
## Why zagora?
160
160
@@ -165,7 +165,7 @@ Both `tRPC` and `oRPC` are promoted as "backend", or specifically for when you'r
165
165
166
166
They are built around the network, Zagora is built around functions with excellent egonomics, developer experience, and no assumptions. **It produces just functions, i cannot stress that enough.**
167
167
168
-
[Back to top](#table-of-contents)
168
+
[**Back to top**](#table-of-contents)
169
169
170
170
### Why Zagora over oRPC/tRPC/neverthrow/effect.ts?
171
171
@@ -196,15 +196,15 @@ They are built around the network, Zagora is built around functions with excelle
196
196
197
197
Funny enough, you can use Zagora to build fully type-safe CLIs with auto-generated detailed help, based on the provided schemas. I have another library for that, which i will overhaul soon - [zodest](https://npmjs.com/package/zodest).
198
198
199
-
[Back to top](#table-of-contents)
199
+
[**Back to top**](#table-of-contents)
200
200
201
201
### Why Zagora over plain TypeScript functions?
202
202
203
203
- Plain TypeScript offers compile-time types but no runtime validation — a mismatch between runtime and
204
204
compile-time can blow up.
205
205
- Zagora combines runtime validation/transforms (StandardSchema) with full compile-time inference, and returns a safe, uniform result tuple inspired by true functional programming
206
206
207
-
[Back to top](#table-of-contents)
207
+
[**Back to top**](#table-of-contents)
208
208
209
209
### Why Zagora over standalone Zod/Valibot usage?
210
210
@@ -216,7 +216,7 @@ Funny enough, you can use Zagora to build fully type-safe CLIs with auto-generat
216
216
- single place to validate inputs/outputs/errors
217
217
- unified non-throwing result shape
218
218
219
-
[Back to top](#table-of-contents)
219
+
[**Back to top**](#table-of-contents)
220
220
221
221
## Features
222
222
@@ -257,7 +257,7 @@ if (!resul3.ok) {
257
257
}
258
258
```
259
259
260
-
[Back to top](#table-of-contents)
260
+
[**Back to top**](#table-of-contents)
261
261
262
262
### Typed Errors
263
263
@@ -300,7 +300,7 @@ Isn't it amazing? You will never see `Error` or `try/catch` blocks again, and ev
300
300
301
301
But wait, there's more: **Type Guards**!
302
302
303
-
[Back to top](#table-of-contents)
303
+
[**Back to top**](#table-of-contents)
304
304
305
305
### Error Type Guards
306
306
@@ -432,7 +432,7 @@ hello('invalid-keys');
432
432
433
433
**Important:** if you want the error validation to actually throw on unknown keys passed to the error helper, then you need to make the error object schema more strict - just like `z.object(...).strict()`.
434
434
435
-
[Back to top](#table-of-contents)
435
+
[**Back to top**](#table-of-contents)
436
436
437
437
### Context Management
438
438
@@ -458,7 +458,7 @@ procedure('charlie');
458
458
// => 'foo-bar has foo -> qux, id = charlie'
459
459
```
460
460
461
-
[Back to top](#table-of-contents)
461
+
[**Back to top**](#table-of-contents)
462
462
463
463
### Object Inputs
464
464
@@ -469,7 +469,7 @@ zagora()
469
469
.callable()
470
470
```
471
471
472
-
[Back to top](#table-of-contents)
472
+
[**Back to top**](#table-of-contents)
473
473
474
474
### Tuple Inputs (Multiple Arguments)
475
475
@@ -512,7 +512,7 @@ fnTwo('Barry', 25) // => Barry is 25, from unknown
512
512
fnTwo('Barry', 33, 'USA') // => Barry is 33, from USA
513
513
```
514
514
515
-
[Back to top](#table-of-contents)
515
+
[**Back to top**](#table-of-contents)
516
516
517
517
### Default Values
518
518
@@ -532,7 +532,7 @@ fn({ name: 'John' }) // age defaults to 18
You can also provide the cache through `.callable({ cache })`. That is useful, if you want to provide it at "execution place", not at "definition place". For example, you'd have a set of procedures written at one place, then throgh "router" or some object that combiens them you want to call them at a `Request/Response` server handler.
648
648
649
-
[Back to top](#table-of-contents)
649
+
[**Back to top**](#table-of-contents)
650
650
651
651
### Environment Variables
652
652
@@ -676,7 +676,7 @@ Also important to note that when `disableOptions` you will loose access to the `
0 commit comments