diff --git a/backend/src/routes/getOnrampQuotes.ts b/backend/src/routes/getOnrampQuotes.ts new file mode 100644 index 0000000..26d0774 --- /dev/null +++ b/backend/src/routes/getOnrampQuotes.ts @@ -0,0 +1,19 @@ +import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify' +import { locked } from '@/db/schema' + +import type { Database } from '@/db/drizzle' + +export function getOnrampQuotes(fastify: FastifyInstance) { + fastify.get('/get-onramp-quotes', async (request, reply) => handleGetOnrampQuotes(fastify.db, request, reply)) +} + +async function handleGetOnrampQuotes(db: Database, _request: FastifyRequest, reply: FastifyReply) { + try { + const onRampQuotes = await db.select({ amount: locked.amount }).from(locked) + + return reply.send({ onRampQuotes }) + } catch (error) { + console.error(error) + return reply.status(500).send({ message: 'Internal server error' }) + } +} diff --git a/backend/src/routes/index.ts b/backend/src/routes/index.ts index c8bd697..16a42b4 100644 --- a/backend/src/routes/index.ts +++ b/backend/src/routes/index.ts @@ -1,7 +1,9 @@ import type { FastifyInstance } from 'fastify' import { getHealthRoute } from './getHealth' +import { getOnrampQuotes } from './getOnrampQuotes' export function declareRoutes(fastify: FastifyInstance) { getHealthRoute(fastify) + getOnrampQuotes(fastify) }