@@ -4,12 +4,17 @@ import { z } from "zod";
4
4
// Booleans are specified as 'true' or 'false' strings.
5
5
const booleanSchema = z . enum ( [ "true" , "false" ] ) ;
6
6
7
+ // Numbers are treated as strings in .env files.
8
+ // coerce helps us convert them to numbers.
9
+ // @see : https://zod.dev/?id=coercion-for-primitives
10
+ const numberSchema = z . coerce . number ( ) ;
11
+
7
12
export const env = createEnv ( {
8
13
server : {
9
14
// Zoekt
10
- ZOEKT_WEBSERVER_URL : z . string ( ) . url ( ) ,
11
- SHARD_MAX_MATCH_COUNT : z . number ( ) . default ( 10000 ) ,
12
- TOTAL_MAX_MATCH_COUNT : z . number ( ) . default ( 100000 ) ,
15
+ ZOEKT_WEBSERVER_URL : z . string ( ) . url ( ) . default ( "http://localhost:6070" ) ,
16
+ SHARD_MAX_MATCH_COUNT : numberSchema . default ( 10000 ) ,
17
+ TOTAL_MAX_MATCH_COUNT : numberSchema . default ( 100000 ) ,
13
18
14
19
// Auth
15
20
AUTH_SECRET : z . string ( ) ,
@@ -31,7 +36,7 @@ export const env = createEnv({
31
36
STRIPE_ENABLE_TEST_CLOCKS : booleanSchema . default ( 'false' ) ,
32
37
33
38
// Misc
34
- CONFIG_MAX_REPOS_NO_TOKEN : z . number ( ) . default ( 500 ) ,
39
+ CONFIG_MAX_REPOS_NO_TOKEN : numberSchema . default ( 500 ) ,
35
40
SOURCEBOT_ROOT_DOMAIN : z . string ( ) . default ( "localhost:3000" ) ,
36
41
NODE_ENV : z . enum ( [ "development" , "test" , "production" ] ) ,
37
42
SOURCEBOT_TELEMETRY_DISABLED : booleanSchema . default ( 'false' ) ,
@@ -45,7 +50,7 @@ export const env = createEnv({
45
50
46
51
// Misc
47
52
NEXT_PUBLIC_SOURCEBOT_VERSION : z . string ( ) . default ( 'unknown' ) ,
48
- NEXT_PUBLIC_POLLING_INTERVAL_MS : z . number ( ) . default ( 5000 ) ,
53
+ NEXT_PUBLIC_POLLING_INTERVAL_MS : numberSchema . default ( 5000 ) ,
49
54
} ,
50
55
// For Next.js >= 13.4.4, you only need to destructure client variables:
51
56
experimental__runtimeEnv : {
0 commit comments