- Clone the repository.
- Install dependencies using
npm install
. - Rename
.env.example
to.env
. - Run the server using
npm run dev
.
- Environment Variables:
PORT
: Port number the server listens on. Default: 5000MONGODB_URI
: URI for MongoDB database.JWT_SECRET
: Secret key for JWT token generation.EXPIRES_IN
: Token expiration time.
- API Endpoints:
-
POST
/api/v1/register
- Description: Register a new user.
- Request Body:
{ "name": "John", "email": "john@example.com", "password": "password" }
- Response:
{ "success": true, "message": "User registered successfully", "data": { ... }, "token": "jwt_token_here" }
-
POST
/api/v1/login
- Description: Log in with existing credentials.
- Request Body:
{ "email": "john@example.com", "password": "password" }
- Response:
{ "success": true, "message": "Login successful", "token": "jwt_token_here" }
-
POST
/api/v1/create-clothes
- Description: Create a new clothes item.
- Request Body:
{ "email": "john@example.com", "data": { "image": "image_url_here", "category": "category_here", "title": "title_here", "description": "description_here", "size": "size_here" } }
- Response:
{ "success": true, "status": 201, "message": "Data created successfully", "data": { ... } }
-
GET
/api/v1/clothes
- Description: Retrieve all clothes items.
- Response:
{ "success": true, "status": 200, "message": "All Data Retrieved successfully", "data": [ ... ] }
-
GET
/api/v1/clothes-by-user/:email
- Description: Retrieve clothes items associated with a specific user.
- Response:
{ "success": true, "status": 200, "message": "All Data Retrieved successfully", "data": [ ... ] }
-
GET
/api/v1/clothes/:id
- Description: Retrieve a single clothes item by ID.
- Response:
{ "success": true, "status": 200, "message": "Data Retrieved successfully", "data": { ... } }
-
PUT
/api/v1/update-clothes/:id
- Description: Update a clothes item by ID.
- Request Body:
{ "image": "updated_image_url", "category": "updated_category", "title": "updated_title", "description": "updated_description", "size": "updated_size" }
- Response:
{ "success": true, "status": 200, "message": "Clothes data updated successfully", "data": { ... } }
-
DELETE
/api/v1/delete-clothes/:id
- Description: Delete a clothes item by ID.
- Response:
{ "success": true, "status": 200, "message": "Clothes data deleted successfully", "data": { ... } }
- GET
/api/v1/aboutUs
- Description: Retrieve information about the clothing store.
- Response:
{ "success": true, "status": 200, "message": "All Data Retrieved successfully", "data": [ ... ] }
bcrypt
: Library for hashing passwords.cors
: Express middleware for enabling CORS.dotenv
: Loads environment variables from .env file.express
: Web framework for Node.js.jsonwebtoken
: Library for generating and verifying JWT tokens.mongodb
: MongoDB driver for Node.js.nodemon
: Utility for automatically restarting the server during development.