Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelotfr committed Nov 1, 2023
1 parent bd1d8c6 commit 48d1f7f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
|-------------------------------------------|-----------------------|
| GET `/health` | Health check
| GET `/sales` | Get sales by `collection_name`, `sale_id`, `timestamp`, `block_number`, `template_id`, `listing_price_amount`, `listing_price_symcode`, `trx_id` or `asset_ids`
| GET `/sales/aggregate` | Get aggregate of sales filtered by `collection_name`, `timestamp` or `block_number`
| GET `/metrics` | Prometheus metrics
| GET `/openapi` | [OpenAPI v3 JSON](https://spec.openapis.org/oas/v3.0.0)

Expand Down
18 changes: 18 additions & 0 deletions src/fetch/aggregate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { makeQuery } from "../clickhouse/makeQuery.js";
import { logger } from "../logger.js";
import { getAggregate } from "../queries.js";
import * as prometheus from "../prometheus.js";

export default async function (req: Request) {
try {
const { searchParams } = new URL(req.url);
logger.info({searchParams: Object.fromEntries(Array.from(searchParams))});
const query = await getAggregate(searchParams);
const response = await makeQuery<number>(query)
return new Response(JSON.stringify(response.data), { headers: { "Content-Type": "application/json" } });
} catch (e: any) {
logger.error(e);
prometheus.request_error.inc({pathname: "/sales/aggregate", status: 400});
return new Response(e.message, { status: 400 });
}
}
2 changes: 1 addition & 1 deletion src/fetch/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default new OpenApiBuilder()
get: {
tags: [TAGS.USAGE],
summary: "Get aggregate of sales",
description: "Get aggregate of sales by `collection_name`, `timestamp` or `block_number`",
description: "Get aggregate of sales filtered by `collection_name`, `timestamp` or `block_number`",
parameters: [
{
name: "aggregate_function",
Expand Down

0 comments on commit 48d1f7f

Please sign in to comment.