From cab97bdb637265e54bb43f37cacb9d4ea868a8cb Mon Sep 17 00:00:00 2001 From: OneEuroQuestion Date: Wed, 10 Jan 2024 21:24:48 +0200 Subject: [PATCH] adding endpoints to list more information --- src/query.ts | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/query.ts b/src/query.ts index af1d14b..3d04645 100644 --- a/src/query.ts +++ b/src/query.ts @@ -462,6 +462,57 @@ server.get('/providers', providersOpts, requestCache.handleRequestWithCache(asyn } })) +const specssOpts: RouteShorthandOptions = { + schema: { + response: { + 200: { + type: 'object', + properties: { + specs: { + type: 'array', + }, + } + } + } + } +} + +server.get('/specs', specssOpts, requestCache.handleRequestWithCache(async (request: FastifyRequest, reply: FastifyReply) => { + await checkDb() + + const res = await db.select().from(schema.specs) + + return { + specs: res, + } +})) + +const consumersOpts: RouteShorthandOptions = { + schema: { + response: { + 200: { + type: 'object', + properties: { + consumers: { + type: 'array', + }, + } + } + } + } +} + +server.get('/consumers', consumersOpts, requestCache.handleRequestWithCache(async (request: FastifyRequest, reply: FastifyReply) => { + await checkDb() + + const res = await db.select().from(schema.consumers) + + return { + consumers: res, + } +})) + + const consumerOpts: RouteShorthandOptions = { schema: { response: {