From e52ab793c589ddb9bb50f9a95ae3696883173621 Mon Sep 17 00:00:00 2001 From: andwati Date: Wed, 14 Jan 2026 13:00:26 +0300 Subject: [PATCH] Updated README.md to enhance formatting and structure, changing section headers from '###' to '##' for better clarity and consistency. Added Swagger documentation link for browser testing. --- README.md | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 260d4d9..9301d49 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Order Service +# Order Service An **order management REST API** with authentication, role-based access control, and MongoDB persistence. It exposes endpoints for: @@ -9,9 +9,11 @@ An **order management REST API** with authentication, role-based access control, Built with **Node.js**, **Express 5**, **TypeScript**, and **Mongoose**. +Swagger doc for test in the browser: + --- -### 1. Setup & Installation +## 1. Setup & Installation - **Prerequisites** - **Node.js**: v20+ recommended @@ -44,7 +46,7 @@ The API will listen on `http://localhost:` (defaults to `3000`). --- -### 2. Environment Variables +## 2. Environment Variables Environment variables are loaded via `dotenv` in `src/config/env.ts`. The following variables are **required/recommended**: @@ -80,7 +82,7 @@ Create a `.env` file at the project root before running the server or scripts. --- -### 3. Database, Migrations & Seeding +## 3. Database, Migrations & Seeding This project uses **MongoDB + Mongoose**. There is no formal migration tool configured; schemas are defined via Mongoose models under `src/models`. @@ -113,7 +115,7 @@ Make sure: --- -### 4. Running the Service +## 4. Running the Service - **Build once:** @@ -138,9 +140,9 @@ The service will: --- -### 5. API Reference & Example `curl` Requests +## 5. API Reference & Example `curl` Requests -#### 5.1 Health Check +## 5.1 Health Check - **GET `/health`** @@ -150,9 +152,9 @@ curl -i https://order-service-t77z.onrender.com/health --- -#### 5.2 Auth +## 5.2 Auth -##### Register +### Register - **POST `/auth/register`** - Body: @@ -169,7 +171,7 @@ curl -i -X POST https://order-service-t77z.onrender.com/auth/register \ For an admin user, set `"role": "admin"`. -##### Login +### Login - **POST `/auth/login`** @@ -190,9 +192,9 @@ Authorization: Bearer --- -#### 5.3 Products +## 5.3 Products -##### List products (public) +### List products (public) - **GET `/products`** @@ -200,7 +202,7 @@ Authorization: Bearer curl -i https://order-service-t77z.onrender.com/products ``` -##### Create product (admin only) +### Create product (admin only) - **POST `/products`** @@ -215,7 +217,7 @@ curl -i -X POST https://order-service-t77z.onrender.com/products \ }' ``` -##### Update product (admin only) +### Update product (admin only) - **PATCH `/products/:id`** @@ -231,9 +233,9 @@ curl -i -X PATCH https://order-service-t77z.onrender.com/products/ \ --- -#### 5.4 Orders +## 5.4 Orders -##### Create order (customer or admin) +### Create order (customer or admin) - **POST `/orders`** @@ -249,7 +251,7 @@ curl -i -X POST https://order-service-t77z.onrender.com/orders \ }' ``` -##### List my orders +### List my orders - **GET `/orders`** @@ -258,7 +260,7 @@ curl -i https://order-service-t77z.onrender.com/orders \ -H "Authorization: Bearer " ``` -##### Pay for an order +### Pay for an order - **POST `/orders/:id/pay`** @@ -267,7 +269,7 @@ curl -i -X POST https://order-service-t77z.onrender.com/orders//pay \ -H "Authorization: Bearer " ``` -##### Cancel an order +### Cancel an order - **POST `/orders/:id/cancel`** @@ -278,9 +280,9 @@ curl -i -X POST https://order-service-t77z.onrender.com/orders//cancel --- -#### 5.5 Users (Admin only) +## 5.5 Users (Admin only) -##### List users +### List users - **GET `/users`** @@ -291,7 +293,7 @@ curl -i https://order-service-t77z.onrender.com/users \ --- -### 6. Swagger / API Docs +## 6. Swagger / API Docs The service is wired with `swagger-jsdoc` and `swagger-ui-express`. OpenAPI annotations live in the route files (e.g. `src/routes/auth.routes.ts`, `src/routes/order.routes.ts`, etc) and are aggregated in the Swagger configuration. @@ -305,7 +307,7 @@ This provides an interactive UI for exploring and testing all endpoints. --- -### 7. Design Notes +## 7. Design Notes - **Architecture** - **Layered structure**: