Endpoint: /
Method: POST
Content-Type: application/json
Send a JSON object with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Full name of the user |
email |
string | Yes | User's email address |
phone |
string | Yes | User's phone number |
rating |
number | Yes | Rating given by the user (e.g., 0.5–5) |
feedback |
string | No | Textual feedback or comments |
POST / HTTP/1.1
Content-Type: application/json
{
"name": "Husain Khorakiwala",
"email": "husain@example.com",
"phone": "9876543210",
"rating": 4.5,
"feedback": "Great experience, everything worked smoothly!"
}Success (200 OK)
{
"message": "Feedback submitted successfully"
}Error (400 Bad Request)
{
"error": "Missing required fields"
}Error (500 Internal Server Error)
{
"error": "Internal server error"
}Endpoint: /
Method: GET
This route is protected and requires the Authorization header with a valid token. The header should be in the following format:
Authorization: <your_token_here>
| Header | Type | Required | Description |
|---|---|---|---|
Authorization |
string | Yes | The token used for authenticating the request |
GET / HTTP/1.1
Authorization: <your_token_here>Success (200 OK)
- It returns a list of all feedbacks
[
{
"id": "16ff4b40-5dae-456e-be0f-4b1637d39251",
"name": "Husain",
"email": "test@gmail.com",
"phone": "9876543210",
"rating": 4,
"feedback": "",
"timestamp": "2025-04-22T05:40:19.724Z"
}
]Error (401 Unauthorized)
{
"error": "Unauthorized"
}Error (400 Bad Request)
{
"error": "Invalid Authorization header format"
}Error (500 Internal Server Error)
{
"error": "Internal server error"
}| Field | Type | Attributes | Description |
|---|---|---|---|
id |
String | @id @default(uuid()) |
Unique identifier (UUID) |
name |
String | – | Full name of the user |
email |
String | – | User's email address |
phone |
String | – | User's phone number |
rating |
Float | – | Rating given by the user (e.g., 1–5) |
feedback |
String | – | User's feedback or comments |
timestamp |
DateTime | @default(now()) |
Automatically set to the current time on creation |
project-root/
├── frontend/ # Next.js application
│ ├── public/ # Static assets
│ ├── components/ # React components
│ └── ... # Config files, styles, etc.
│
├── backend/ # Express.js + TypeScript backend
│ ├── src/
│ │ ├── config/ # DB config, env setup
│ │ ├── middlewares/ # Express middlewares (e.g. auth)
│ │ ├── routes/ # Route handlers
│ │ └── index.ts # Express entry point
│ │
│ ├── prisma/ # Prisma setup
│ │ ├── schema.prisma # Main DB schema
│ │ ├── migrations/ # DB migration history
│ │ └── generated/ # Prisma client
│ │
│ └── package.json # Backend dependencies
│
├── .gitignore
└── README.md
- Problem: The frontend couldn’t access the backend API due to missing CORS headers.
- Solution: Added CORS middleware in Express:
