Skip to content

Commit

Permalink
remove where
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Sep 23, 2024
1 parent e7f9d52 commit 6788729
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "antelope-transactions-api",
"description": "Transactions information from the Antelope blockchains",
"version": "0.3.2",
"version": "0.3.3",
"homepage": "https://github.com/pinax-network/antelope-transactions-api",
"license": "MIT",
"authors": [
Expand Down
1 change: 1 addition & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TsLogger extends Logger<ILogObj> {

public enable(type: "pretty" | "json" = "json") {
this.settings.type = type;
this.settings.hideLogPositionForProduction = true;
this.settings.minLevel = 0;
this.info("Enabled logger");
}
Expand Down
10 changes: 5 additions & 5 deletions src/typespec/openapi3.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using TypeSpec.OpenAPI;
name: "MIT",
url: "https://github.com/pinax-network/antelope-transactions-api/blob/75db1c61477ac7ea5e56f775cefe54875af953d4/LICENSE",
},
version: "0.3.2",
version: "0.3.3",
}) // From @typespec/openapi
//@server("https://eos.api.pinax.network/v1", "EOS V1 Api Endpoint")
namespace AntelopeTransactionsApi;
Expand Down Expand Up @@ -50,10 +50,10 @@ model UsageResponse<T> {
};
rows: safeint;
rows_before_limit_at_least: safeint;
meta: {
name: string;
type: string;
}[];
// meta: {
// name: string;
// type: string;
// }[];
}

// Alias will *not* be present in the OpenAPI components.
Expand Down
8 changes: 6 additions & 2 deletions src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
if (["limit", "offset", "order_by", "order_direction", "skip", "first"].includes(key)) continue; // skip pagination params
const value = (query_params as any)[key];
let isNumber = !isNaN(Number(value));
where.push(`"${key}" = {${key}: ${isNumber ? "int" : "String"}}`);
// where.push(`${key} = {${key}: ${isNumber ? "int" : "String"}}`);
where.push(`${key}='${value}'`);
}
if (where.length) query.push(`WHERE ${where.join(" AND ")}`);

Expand All @@ -45,7 +46,10 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
if (query_params.offset) query.push("OFFSET {offset: int}");

try {
return ctx.json(await makeQuery<UsageElementReturnType>(query.join(" "), { ...query_params }));
const result = await makeQuery<UsageElementReturnType>(query.join(" "), { ...query_params });
// Remove the `meta` key from the response
if (result.meta) delete result.meta;
return ctx.json(result);
} catch (err) {
return APIErrorResponse(ctx, 500, "bad_database_response", err);
}
Expand Down

0 comments on commit 6788729

Please sign in to comment.