README
This commit is contained in:
parent
d12e2581b6
commit
ae3e0c6e2c
1 changed files with 61 additions and 86 deletions
147
README.md
147
README.md
|
@ -1,98 +1,73 @@
|
||||||
# Ecomm #
|
# Ecomm Backend
|
||||||
|
|
||||||
## Description ##
|
This repository contains the backend implementation for the Ecomm e-commerce application.
|
||||||
This is a simple e-commerce backend application.
|
|
||||||
|
|
||||||
Technologies used:
|
## Description
|
||||||
|
|
||||||
* Node.js
|
This is a simple e-commerce backend application built with Node.js, TypeScript, Express.js, MongoDB, and Docker. It provides API endpoints to manage users and products.
|
||||||
* typescript
|
|
||||||
* Express.js
|
|
||||||
* MongoDB
|
|
||||||
* Mongoose ORM
|
|
||||||
* Docker (docker-compose)
|
|
||||||
* bcrypt
|
|
||||||
* JWT
|
|
||||||
|
|
||||||
## How to run ##
|
## Table of Contents
|
||||||
1. Clone the repository
|
|
||||||
2. Make sure you have docker and docker-compose installed
|
|
||||||
3. Implement the .env file
|
|
||||||
4. Run `docker-compose up` in the root directory
|
|
||||||
The application will be running on port 3000
|
|
||||||
The database will be running on port 27017
|
|
||||||
|
|
||||||
# API #
|
- [Technologies Used](#technologies-used)
|
||||||
app.use('/products', productRouter);
|
- [How to Run](#how-to-run)
|
||||||
app.use('/cart', cartRouter);
|
- [API Documentation](#api-documentation)
|
||||||
|
- [Users](#users)
|
||||||
|
- [Create a New User](#create-a-new-user---post-users)
|
||||||
|
- [Login](#login---post-userslogin)
|
||||||
|
- [Products](#products)
|
||||||
|
- [Get All Products](#get-all-products---get-products)
|
||||||
|
|
||||||
## Users ##
|
## Technologies Used
|
||||||
## POST /users ## - Create a new user
|
|
||||||
### Request body ###
|
- Node.js
|
||||||
```json
|
- TypeScript
|
||||||
|
- Express.js
|
||||||
|
- MongoDB
|
||||||
|
- Mongoose ORM
|
||||||
|
- Docker (docker-compose)
|
||||||
|
- bcrypt
|
||||||
|
- JWT
|
||||||
|
|
||||||
|
## How to Run
|
||||||
|
|
||||||
|
To run the Ecomm backend application, follow these steps:
|
||||||
|
|
||||||
|
1. Clone the repository.
|
||||||
|
2. Ensure that you have Docker and Docker Compose installed.
|
||||||
|
3. Implement the required environment variables by creating an `.env` file.
|
||||||
|
4. Run the following command in the root directory:
|
||||||
|
```shell
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
|
The application will be running on port 3000, and the database will be running on port 27017.
|
||||||
|
|
||||||
|
API Documentation
|
||||||
|
Users
|
||||||
|
Create a New User - POST /users
|
||||||
|
Creates a new user.
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
|
||||||
|
```
|
||||||
{
|
{
|
||||||
|
"name": "string",
|
||||||
|
"email": "string",
|
||||||
|
"password": "string"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Response Body
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"user": {
|
||||||
|
"_id": "string",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"email": "string",
|
"email": "string",
|
||||||
"password": "string"
|
"password": "string",
|
||||||
}
|
"createdAt": "string",
|
||||||
```
|
"updatedAt": "string",
|
||||||
### Response body ###
|
"__v": "number"
|
||||||
```json
|
},
|
||||||
{
|
"token": "string"
|
||||||
"user": {
|
|
||||||
"_id": "string",
|
|
||||||
"name": "string",
|
|
||||||
"email": "string",
|
|
||||||
"password": "string",
|
|
||||||
"createdAt": "string",
|
|
||||||
"updatedAt": "string",
|
|
||||||
"__v": "number"
|
|
||||||
},
|
|
||||||
"token": "string"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## POST /users/login ## - Login
|
|
||||||
### Request body ###
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"email": "string",
|
|
||||||
"password": "string"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
### Response ###
|
|
||||||
# body #
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"access-token": "string"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
# headers #
|
|
||||||
``` Cookie - "access-token"": "string" ```
|
|
||||||
|
|
||||||
|
|
||||||
## Products ##
|
|
||||||
## GET /products ## - Get all products
|
|
||||||
accepts query params: page, limit. Default values: page = 0, limit = 50.
|
|
||||||
### Response body ###
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"_id": "string",
|
|
||||||
"name": "string",
|
|
||||||
"description": "string",
|
|
||||||
"price": "number",
|
|
||||||
"createdAt": "string",
|
|
||||||
"updatedAt": "string",
|
|
||||||
"__v": "number"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"total": "number"
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue