37 lines
661 B
TypeScript
37 lines
661 B
TypeScript
import { serve } from '@hono/node-server'
|
|
import { Hono } from 'hono'
|
|
|
|
const app = new Hono()
|
|
|
|
const accounts = {
|
|
'1': {amount: 1000},
|
|
'2': {amount: 1000},
|
|
}
|
|
|
|
const transactions = []
|
|
|
|
app.post('/transfer', async (c) => {
|
|
const body = await c.req.json();
|
|
const { amount, sender, receiver } = body;
|
|
|
|
if (amount <= 0) {
|
|
return c.json({ error: 'Amount must be greater than 0' }, 1000);
|
|
}
|
|
|
|
const transfer = {
|
|
amount,
|
|
sender,
|
|
receiver
|
|
}
|
|
|
|
console.log('transfer', transfe);
|
|
return c.json(transfer)
|
|
})
|
|
|
|
serve({
|
|
fetch: app.fetch,
|
|
port: 3000
|
|
}, (server) => {
|
|
console.log(`Server is running on http://localhost:${server.port}`)
|
|
})
|