Skip to content

Commit 0247275

Browse files
author
Igor Lins e Silva
committed
[api] add skip/limit to get_tokens
1 parent 3a7d422 commit 0247275

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

api/routes/v2-state/get_tokens/get_tokens.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import {ServerResponse} from "http";
22
import {timedQuery} from "../../../helpers/functions";
33
import {FastifyInstance, FastifyReply, FastifyRequest} from "fastify";
4+
import {getSkipLimit} from "../../v2-history/get_actions/functions";
45

56

67
async function getTokens(fastify: FastifyInstance, request: FastifyRequest) {
78

89
const response = {'account': request.query.account, 'tokens': []};
910

11+
const {skip, limit} = getSkipLimit(request.query);
12+
const maxDocs = fastify.manager.config.api.limits.get_tokens ?? 100;
13+
1014
const stateResult = await fastify.elastic.search({
1115
"index": fastify.manager.chain + '-table-accounts-*',
16+
"size": (limit > maxDocs ? maxDocs : limit) || 10,
17+
"from": skip || 0,
1218
"body": {
1319
query: {
1420
bool: {

0 commit comments

Comments
 (0)