rename directories
This commit is contained in:
36
js-hono/src/index.ts
Normal file
36
js-hono/src/index.ts
Normal file
@ -0,0 +1,36 @@
|
||||
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}`)
|
||||
})
|
||||
Reference in New Issue
Block a user