From 392bd0f803ad3db1502c8534b8276b6f228e28e5 Mon Sep 17 00:00:00 2001 From: Etienne Donneger <23462475+Krow10@users.noreply.github.com> Date: Sun, 15 Oct 2023 06:07:07 -0400 Subject: [PATCH] Fix rebase Support passing arrays for query parameters (#10) * Add `block_number` array query support The `/{chain}/timestamp` endpoint can now accept a single or an array of block numbers (comma-separated). A maximum number of values to be parsed can be set using the MAX_ELEMENTS_QUERIED env variable (will be shared with `/{chain}/blocknum`). Related: #5 * Refactor API responses to serve array queries - Changed the default Clickhouse DB response format to `JSONObjectEachRow` in order to have query parameters matching with the response value. - JSON responses are parsed directly from the schemas to ensure consistency. Closes: #5 --- src/config.ts | 2 +- src/schemas.ts | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/config.ts b/src/config.ts index 7d9119e..2a5b54b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -49,4 +49,4 @@ const opts = new Command() .parse(process.argv).opts(); let config: z.infer = decode({...opts, ...process.env}); -export default config!; \ No newline at end of file +export default config!; diff --git a/src/schemas.ts b/src/schemas.ts index 5fcc86e..bb818e5 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -52,8 +52,6 @@ export const BlockchainSchema = z.object({ }) }); -// Represents the timestamp query parameter for `/{c}/timestamp?blocknum=` endpoint -// Supports array parsing via comma-separated values export const BlocknumSchema = z.object({ block_number: z.union([ z_blocknum, @@ -68,8 +66,6 @@ export const BlocknumSchema = z.object({ }) }); -// Represents the timestamp query parameter for `/{c}/blocknum?timestamp=` endpoint -// Supports array parsing via comma-separated values export const TimestampSchema = z.object({ timestamp: z.union([ z_timestamp, @@ -116,4 +112,4 @@ export type TimestampSchema = z.infer; export type BlocktimeQueryResponseSchema = z.infer; export type BlocktimeQueryResponsesSchema = z.infer; export type SingleBlocknumQueryResponseSchema = z.infer; -export type SupportedChainsQueryResponseSchema = z.infer; \ No newline at end of file +export type SupportedChainsQueryResponseSchema = z.infer;