add transfer route
This commit is contained in:
@ -3,8 +3,23 @@ import { Hono } from 'hono'
|
|||||||
|
|
||||||
const app = new Hono()
|
const app = new Hono()
|
||||||
|
|
||||||
app.get('/', (c) => {
|
app.post('/transfer', async (c) => {
|
||||||
return c.text('Hello Hono!')
|
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({
|
serve({
|
||||||
|
|||||||
Reference in New Issue
Block a user