-
Notifications
You must be signed in to change notification settings - Fork 15
Build ENSRainbow config #1425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Build ENSRainbow config #1425
Changes from all commits
c34c0bd
bbe487e
6acc196
22a81f0
03722ac
ec75cfe
887aecc
bd1dd1c
1ddfc33
3b5c7cc
782e329
2e1f9d9
ddaaf29
a43b125
c57e7f6
e3a6c90
8dc1b6e
eac29d6
d165cd5
79cc9ad
b9a41e9
096049a
f4859d7
3d9399f
e735747
5bafcdb
7a646e0
9d12088
89ff961
832abff
363208c
30873a0
7d7a1f6
2d7207d
100cda3
9a00f37
e834196
75e72f8
70389d4
163f873
71a2885
4cca4f7
54bf472
aeb14c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "ensrainbow": patch | ||
| "@ensnode/ensrainbow-sdk": patch | ||
| --- | ||
|
|
||
| Adds `/v1/config` endpoint to ENSRainbow API returning public configuration (version, label set, records count) and deprecates `/v1/version` endpoint. The new endpoint provides comprehensive service discovery capabilities for clients. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import config from "@/config"; | ||
|
|
||
|
Comment on lines
+1
to
+2
|
||
| import { join, resolve } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
|
|
@@ -6,6 +8,7 @@ import { hideBin } from "yargs/helpers"; | |
| import yargs from "yargs/yargs"; | ||
|
|
||
| import { buildLabelSetId, type LabelSetId } from "@ensnode/ensnode-sdk"; | ||
| import { PortSchemaBase } from "@ensnode/ensnode-sdk/internal"; | ||
|
|
||
| import { convertCommand } from "@/commands/convert-command-sql"; | ||
| import { convertCsvCommand } from "@/commands/convert-csv-command"; | ||
|
|
@@ -14,17 +17,6 @@ import { ingestProtobufCommand } from "@/commands/ingest-protobuf-command"; | |
| import { purgeCommand } from "@/commands/purge-command"; | ||
| import { serverCommand } from "@/commands/server-command"; | ||
| import { validateCommand } from "@/commands/validate-command"; | ||
| import { getDefaultDataSubDir, getEnvPort } from "@/lib/env"; | ||
|
|
||
| export function validatePortConfiguration(cliPort: number): void { | ||
| const envPort = process.env.PORT; | ||
| if (envPort !== undefined && cliPort !== getEnvPort()) { | ||
| throw new Error( | ||
| `Port conflict: Command line argument (${cliPort}) differs from PORT environment variable (${envPort}). ` + | ||
| `Please use only one method to specify the port.`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // interface IngestArgs { | ||
| // "input-file": string; | ||
|
|
@@ -36,6 +28,11 @@ interface IngestProtobufArgs { | |
| "data-dir": string; | ||
| } | ||
|
|
||
| /** | ||
| * Arguments for the 'serve' command. | ||
| * | ||
| * Note: CLI arguments take precedence over environment variables. | ||
| */ | ||
djstrong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| interface ServeArgs { | ||
| port: number; | ||
| "data-dir": string; | ||
|
|
@@ -89,7 +86,7 @@ export function createCLI(options: CLIOptions = {}) { | |
| // .option("data-dir", { | ||
| // type: "string", | ||
| // description: "Directory to store LevelDB data", | ||
| // default: getDefaultDataSubDir(), | ||
| // default: getDefaultDataDir(), | ||
djstrong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // }); | ||
| // }, | ||
| // async (argv: ArgumentsCamelCase<IngestArgs>) => { | ||
|
|
@@ -112,7 +109,7 @@ export function createCLI(options: CLIOptions = {}) { | |
| .option("data-dir", { | ||
| type: "string", | ||
| description: "Directory to store LevelDB data", | ||
| default: getDefaultDataSubDir(), | ||
| default: config.dataDir, | ||
| }); | ||
| }, | ||
| async (argv: ArgumentsCamelCase<IngestProtobufArgs>) => { | ||
|
|
@@ -129,17 +126,24 @@ export function createCLI(options: CLIOptions = {}) { | |
| return yargs | ||
| .option("port", { | ||
| type: "number", | ||
| description: "Port to listen on", | ||
| default: getEnvPort(), | ||
| description: "Port to listen on (overrides PORT env var if both are set)", | ||
| default: config.port, | ||
djstrong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| coerce: (port: number) => { | ||
| const result = PortSchemaBase.safeParse(port); | ||
| if (!result.success) { | ||
| const firstError = result.error.issues[0]; | ||
| throw new Error(`Invalid port: ${firstError?.message ?? "invalid port number"}`); | ||
| } | ||
| return result.data; | ||
| }, | ||
|
Comment on lines
131
to
138
|
||
| }) | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .option("data-dir", { | ||
| type: "string", | ||
| description: "Directory containing LevelDB data", | ||
| default: getDefaultDataSubDir(), | ||
| default: config.dataDir, | ||
| }); | ||
| }, | ||
| async (argv: ArgumentsCamelCase<ServeArgs>) => { | ||
djstrong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| validatePortConfiguration(argv.port); | ||
| await serverCommand({ | ||
| port: argv.port, | ||
| dataDir: argv["data-dir"], | ||
|
|
@@ -154,7 +158,7 @@ export function createCLI(options: CLIOptions = {}) { | |
| .option("data-dir", { | ||
| type: "string", | ||
| description: "Directory containing LevelDB data", | ||
| default: getDefaultDataSubDir(), | ||
| default: config.dataDir, | ||
| }) | ||
| .option("lite", { | ||
| type: "boolean", | ||
|
|
@@ -177,7 +181,7 @@ export function createCLI(options: CLIOptions = {}) { | |
| return yargs.option("data-dir", { | ||
| type: "string", | ||
| description: "Directory containing LevelDB data", | ||
| default: getDefaultDataSubDir(), | ||
| default: config.dataDir, | ||
| }); | ||
| }, | ||
| async (argv: ArgumentsCamelCase<PurgeArgs>) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Avoid fixed sleeps when waiting for server startup.
Fixed delays can be flaky under load; polling the health endpoint with a timeout will make these tests more reliable.
♻️ Suggested refactor for reliable startup waits
Also applies to: 556-558, 626-628
🤖 Prompt for AI Agents