add transfer route
This commit is contained in:
@ -3,8 +3,23 @@ import { Hono } from 'hono'
|
||||
|
||||
const app = new Hono()
|
||||
|
||||
app.get('/', (c) => {
|
||||
return c.text('Hello Hono!')
|
||||
app.post('/transfer', async (c) => {
|
||||
const body = await c.req.json();
|
||||
const { amount, from, to } = body;
|
||||
|
||||
if (amount <= 0) {
|
||||
return c.json({ error: 'Amount must be greater than 0' }, 400);
|
||||
}
|
||||
|
||||
const transfer = {
|
||||
amount,
|
||||
from,
|
||||
to
|
||||
}
|
||||
|
||||
console.log(transfer);
|
||||
|
||||
return c.json(transfer)
|
||||
})
|
||||
|
||||
serve({
|
||||
|
||||
Reference in New Issue
Block a user