1
2
3
4
5
notification-service/
├── src/
│ └── index.js
├── .env
├── package.json
1
2
3
mkdir notification-service
cd notification-service
npm init -y
1
npm install hono dotenv
1
2
mkdir controllers models routes middlewares
touch server.js .env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { Hono } from 'hono';
import { logger } from 'hono/logger';
import { cors } from 'hono/cors';
const app = new Hono();
// Middleware
app.use('*', logger());
app.use('*', cors());
// POST /notify
app.post('/notify', async (c) => {
const body = await c.req.json();
console.log('New notification received:', body);
return c.json({ message: 'Notification logged.' }, 200);
});
export default app;
1
2
3
"scripts": {
"dev": "node --watch src/index.js"
}
1
npm run dev
By default, Hono runs on port 3000. You can also customize this if needed.
1
2
3
4
5
{
"type": "order_created",
"message": "New order #01234 created for user ID 789",
"timestamp": "2025-07-17T10:00:00Z"
}
1
2
3
{
"message": "Notification logged."
}
1
2
3
4
5
New notification received: {
type: 'order_created',
message: 'New order #01234 created for user ID 789',
timestamp: '2025-07-17T10:00:00Z'
}