Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvolek committed Dec 5, 2023
1 parent 86497a2 commit 86d08a4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"cdbsync",
"dbsync",
"delegators",
"Drep",
"dreps",
"elgohr",
"emurgo",
Expand Down
3 changes: 2 additions & 1 deletion src/routes/governance/dreps/hash/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import * as QueryTypes from '../../../../types/queries/blocks.js';
import * as ResponseTypes from '../../../../types/responses/blocks.js';
import { getDbSync } from '../../../../utils/database.js';
import { SQLQuery } from '../../../../sql/index.js';
import { DrepRequestParameters } from '../../../../types/queries/governance.js';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:hash/distribution',
method: 'GET',
// TODO: add schema when available
// schema: getSchemaForEndpoint('/governance/dreps/{hash}/distribution'),
handler: async (request: FastifyRequest<QueryTypes.RequestParameters>, reply) => {
handler: async (request: FastifyRequest<DrepRequestParameters>, reply) => {
const clientDbSync = await getDbSync(fastify);

const { rows }: { rows: ResponseTypes.Block[] } = await clientDbSync.query<QueryTypes.Block>(
Expand Down
3 changes: 2 additions & 1 deletion src/routes/governance/dreps/hash/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import * as ResponseTypes from '../../../../types/responses/blocks.js';
import { getDbSync } from '../../../../utils/database.js';
import { handle404 } from '../../../../utils/error-handler.js';
import { SQLQuery } from '../../../../sql/index.js';
import { DrepRequestParameters } from '../../../../types/queries/governance.js';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps/:hash',
method: 'GET',
// TODO: add schema when available
// schema: getSchemaForEndpoint('/governance/dreps/{hash}'),
handler: async (request: FastifyRequest<QueryTypes.RequestParameters>, reply) => {
handler: async (request: FastifyRequest<DrepRequestParameters>, reply) => {
const clientDbSync = await getDbSync(fastify);

const { rows }: { rows: ResponseTypes.Block[] } = await clientDbSync.query<QueryTypes.Block>(
Expand Down
3 changes: 2 additions & 1 deletion src/routes/governance/dreps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { SQLQuery } from '../../../sql/index.js';
import * as QueryTypes from '../../../types/queries/epochs.js';
import * as ResponseTypes from '../../../types/responses/epochs.js';
import { getDbSync } from '../../../utils/database.js';
import { DrepRequestParameters } from '../../../types/queries/governance.js';

async function route(fastify: FastifyInstance) {
fastify.route({
url: '/governance/dreps',
method: 'GET',
// TODO: add schema when available
// schema: getSchemaForEndpoint('/epochs/latest'),
handler: async (request: FastifyRequest<QueryTypes.RequestParameters>, reply) => {
handler: async (request: FastifyRequest<DrepRequestParameters>, reply) => {
const clientDbSync = await getDbSync(fastify);

try {
Expand Down
12 changes: 12 additions & 0 deletions src/types/queries/governance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Order } from '../common.js';

export interface DrepRequestParameters {
Params: {
hash: string;
};
Querystring: {
count: number;
page: number;
order: Order;
};
}

0 comments on commit 86d08a4

Please sign in to comment.