@@ -4,12 +4,17 @@ import { z } from "zod";
44// Booleans are specified as 'true' or 'false' strings.
55const booleanSchema = z . enum ( [ "true" , "false" ] ) ;
66
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+
712export const env = createEnv ( {
813 server : {
914 // 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 ) ,
1318
1419 // Auth
1520 AUTH_SECRET : z . string ( ) ,
@@ -31,7 +36,7 @@ export const env = createEnv({
3136 STRIPE_ENABLE_TEST_CLOCKS : booleanSchema . default ( 'false' ) ,
3237
3338 // Misc
34- CONFIG_MAX_REPOS_NO_TOKEN : z . number ( ) . default ( 500 ) ,
39+ CONFIG_MAX_REPOS_NO_TOKEN : numberSchema . default ( 500 ) ,
3540 SOURCEBOT_ROOT_DOMAIN : z . string ( ) . default ( "localhost:3000" ) ,
3641 NODE_ENV : z . enum ( [ "development" , "test" , "production" ] ) ,
3742 SOURCEBOT_TELEMETRY_DISABLED : booleanSchema . default ( 'false' ) ,
@@ -45,7 +50,7 @@ export const env = createEnv({
4550
4651 // Misc
4752 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 ) ,
4954 } ,
5055 // For Next.js >= 13.4.4, you only need to destructure client variables:
5156 experimental__runtimeEnv : {
0 commit comments