Skip to content

Commit

Permalink
fix(cip-1694): enable schema for delgators and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
1000101 committed Dec 17, 2023
1 parent 3ba9b33 commit 14b9f34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/routes/governance/dreps/drep-id/delegators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import * as QueryTypes from '../../../../types/queries/governance.js';
import * as ResponseTypes from '../../../../types/responses/governance.js';
import { getDbSync } from '../../../../utils/database.js';
import { SQLQuery } from '../../../../sql/index.js';
//import { getSchemaForEndpoint } from '@blockfrost/openapi';
import { getSchemaForEndpoint } from '@blockfrost/openapi';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:drep_id/delegators',
method: 'GET',
// TODO: SCHEMA
// schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/delegators'),
schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/delegators'),

handler: async (request: FastifyRequest<QueryTypes.RequestParametersDRepID>, reply) => {
const clientDbSync = await getDbSync(fastify);
Expand Down
7 changes: 3 additions & 4 deletions src/routes/governance/dreps/drep-id/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ import * as QueryTypes from '../../../../types/queries/governance.js';
import * as ResponseTypes from '../../../../types/responses/governance.js';
import { getDbSync } from '../../../../utils/database.js';
import { SQLQuery } from '../../../../sql/index.js';
//import { getSchemaForEndpoint } from '@blockfrost/openapi';
import { getSchemaForEndpoint } from '@blockfrost/openapi';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:drep_id/updates',
method: 'GET',
// TODO: SCHEMA
// schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/updates'),
schema: getSchemaForEndpoint('/governance/dreps/{drep_id}/updates'),

handler: async (request: FastifyRequest<QueryTypes.RequestParametersDRepID>, reply) => {
const clientDbSync = await getDbSync(fastify);

const { rows }: { rows: ResponseTypes.DRepsDrepIDUpdates } =
await clientDbSync.query<QueryTypes.DRepsDrepIDUpdates>(
SQLQuery.get('governance_dreps_drep_id_updates'),
[request.query.order, request.query.count, request.query.page, request.params.drep_id],
[(request.query.order, request.query.count, request.query.page, request.params.drep_id)],
);

clientDbSync.release();
Expand Down

0 comments on commit 14b9f34

Please sign in to comment.