Skip to content

Commit

Permalink
Fix rebase
Browse files Browse the repository at this point in the history
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
  • Loading branch information
0237h committed Oct 17, 2023
1 parent bd858d8 commit 392bd0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ const opts = new Command()
.parse(process.argv).opts();

let config: z.infer<typeof CommanderSchema> = decode({...opts, ...process.env});
export default config!;
export default config!;
6 changes: 1 addition & 5 deletions src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -116,4 +112,4 @@ export type TimestampSchema = z.infer<typeof TimestampSchema>;
export type BlocktimeQueryResponseSchema = z.infer<typeof BlocktimeQueryResponseSchema>;
export type BlocktimeQueryResponsesSchema = z.infer<typeof BlocktimeQueryResponsesSchema>;
export type SingleBlocknumQueryResponseSchema = z.infer<typeof SingleBlocknumQueryResponseSchema>;
export type SupportedChainsQueryResponseSchema = z.infer<typeof SupportedChainsQueryResponseSchema>;
export type SupportedChainsQueryResponseSchema = z.infer<typeof SupportedChainsQueryResponseSchema>;

0 comments on commit 392bd0f

Please sign in to comment.