Objectives

1. Microservice Overview

2. Structure architechture

1
2
3
4
5
notification-service/
├── src/
│   └── index.js
├── .env
├── package.json

2.1. Project Setup

2.2. Create the Notification API

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;

2.3. Run the Server

3. Testing with Postman

1
2
3
{
  "message": "Notification logged."
}