This commit is contained in:
Kfir Dayan 2023-06-11 12:57:27 +03:00
parent d12e2581b6
commit ae3e0c6e2c

119
README.md
View file

@ -1,43 +1,62 @@
# Ecomm #
# Ecomm Backend
## Description ##
This is a simple e-commerce backend application.
This repository contains the backend implementation for the Ecomm e-commerce application.
Technologies used:
## Description
* Node.js
* typescript
* Express.js
* MongoDB
* Mongoose ORM
* Docker (docker-compose)
* bcrypt
* JWT
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.
## How to run ##
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
## Table of Contents
# API #
app.use('/products', productRouter);
app.use('/cart', cartRouter);
- [Technologies Used](#technologies-used)
- [How to Run](#how-to-run)
- [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 ##
## POST /users ## - Create a new user
### Request body ###
```json
## Technologies Used
- Node.js
- 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 ###
```json
Response Body
```
{
"user": {
"_id": "string",
@ -51,48 +70,4 @@ app.use('/cart', cartRouter);
"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"
}
```