1- import { parse as parseConnectionString } from "pg-connection-string" ;
21import { prettifyError , ZodError , z } from "zod/v4" ;
32
43import { buildBlockNumberRange , PluginName , uniq } from "@ensnode/ensnode-sdk" ;
54import {
65 buildRpcConfigsFromEnv ,
76 ENSNamespaceSchema ,
8- EnsIndexerSchemaNameSchema ,
97 invariant_isSubgraphCompatibleRequirements ,
108 invariant_rpcConfigsSpecifiedForRootChain ,
119 makeFullyPinnedLabelSetSchema ,
@@ -14,6 +12,7 @@ import {
1412} from "@ensnode/ensnode-sdk/internal" ;
1513
1614import { DEFAULT_SUBGRAPH_COMPAT } from "@/config/defaults" ;
15+ import ensDbConfig from "@/config/ensdb-config" ;
1716import type { ENSIndexerEnvironment } from "@/config/environment" ;
1817import { applyDefaults , EnvironmentDefaults } from "@/config/environment-defaults" ;
1918
@@ -27,24 +26,6 @@ import {
2726 invariant_validContractConfigs ,
2827} from "./validations" ;
2928
30- export const EnsDbUrlSchema = z . string ( ) . refine (
31- ( url ) => {
32- try {
33- if ( ! url . startsWith ( "postgresql://" ) && ! url . startsWith ( "postgres://" ) ) {
34- return false ;
35- }
36- const config = parseConnectionString ( url ) ;
37- return ! ! ( config . host && config . port && config . database ) ;
38- } catch {
39- return false ;
40- }
41- } ,
42- {
43- error :
44- "Invalid PostgreSQL connection string for ENSDb. Expected format: postgresql://username:password@host:port/database" ,
45- } ,
46- ) ;
47-
4829// parses an env string bool with strict requirement of 'true' or 'false'
4930const makeEnvStringBoolSchema = ( envVarKey : string ) =>
5031 z
@@ -106,8 +87,6 @@ const IsSubgraphCompatibleSchema =
10687
10788const ENSIndexerConfigSchema = z
10889 . object ( {
109- ensDbUrl : EnsDbUrlSchema ,
110- ensIndexerSchemaName : EnsIndexerSchemaNameSchema ,
11190 rpcConfigs : RpcConfigsSchema ,
11291
11392 namespace : ENSNamespaceSchema ,
@@ -116,6 +95,10 @@ const ENSIndexerConfigSchema = z
11695 globalBlockrange : BlockrangeSchema ,
11796 ensRainbowUrl : EnsRainbowUrlSchema ,
11897 labelSet : LabelSetSchema ,
98+
99+ // include the ENSDbConfig params in the ENSIndexerConfigSchema
100+ ensDbUrl : z . string ( ) ,
101+ ensIndexerSchemaName : z . string ( ) ,
119102 } )
120103 /**
121104 * Derived configuration
@@ -184,8 +167,6 @@ export function buildConfigFromEnvironment(_env: ENSIndexerEnvironment): EnsInde
184167
185168 // parse/validate with ENSIndexerConfigSchema
186169 return ENSIndexerConfigSchema . parse ( {
187- ensDbUrl : env . ENSDB_URL ,
188- ensIndexerSchemaName : env . ENSINDEXER_SCHEMA_NAME ,
189170 namespace : env . NAMESPACE ,
190171 rpcConfigs,
191172
@@ -200,6 +181,10 @@ export function buildConfigFromEnvironment(_env: ENSIndexerEnvironment): EnsInde
200181 labelSetId : env . LABEL_SET_ID ,
201182 labelSetVersion : env . LABEL_SET_VERSION ,
202183 } ,
184+
185+ // include the validated ENSDb config values in the parsed EnsIndexerConfig
186+ ensDbUrl : ensDbConfig . ensDbUrl ,
187+ ensIndexerSchemaName : ensDbConfig . ensIndexerSchemaName ,
203188 } ) ;
204189 } catch ( error ) {
205190 if ( error instanceof ZodError ) {
0 commit comments