Skip to content

Commit

Permalink
feat: add get_offramp_quotes endpoint (#63)
Browse files Browse the repository at this point in the history
* Adding getOfframpQuotes endpoint

* fix prettier

---------

Co-authored-by: 0xChqrles <[email protected]>
  • Loading branch information
Gerson2102 and 0xChqrles authored Sep 11, 2024
1 parent 980cccf commit c33bdaf
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, FastifyReply, FastifyRequest } from 'fastify'

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

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 c33bdaf

Please sign in to comment.