From 6deae3fcdb2a62daf87483b6726796978d043647 Mon Sep 17 00:00:00 2001 From: Mohamad Fadhil Date: Tue, 8 Jul 2025 03:20:50 +0800 Subject: [PATCH] add transfer route --- hono/src/index.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hono/src/index.ts b/hono/src/index.ts index bc1cc19..48d79c0 100644 --- a/hono/src/index.ts +++ b/hono/src/index.ts @@ -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({