Skip to content

Commit

Permalink
Adding getOfframpQuotes endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerson2102 committed Sep 10, 2024
1 parent 980cccf commit 759e2ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions backend/src/routes/getOfframpQuotes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'
import { locked } from '@/db/schema'

import type { Database } from '@/db/drizzle'

export function getOfframpQuotes(fastify: FastifyInstance) {
fastify.get('/get-offramp-quotes', async (request, reply) => handleGetOfframpQuotes(fastify.db, request, reply))
}

async function handleGetOfframpQuotes(db: Database, _request: FastifyRequest, reply: FastifyReply) {
try {
const offRampQuotes = await db.select({ amount: locked.amount }).from(locked)

return reply.send({ offRampQuotes })
} catch (error) {
console.error(error)
return reply.status(500).send({ message: 'Internal server error' })
}
}
2 changes: 2 additions & 0 deletions backend/src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { FastifyInstance } from 'fastify'

import { getHealthRoute } from './getHealth'
import { getOfframpQuotes } from './getOfframpQuotes'

export function declareRoutes(fastify: FastifyInstance) {
getHealthRoute(fastify)
getOfframpQuotes(fastify)
}

0 comments on commit 759e2ee

Please sign in to comment.