Giter VIP home page Giter VIP logo

thayrov / backend Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16.05 MB

This project is an educational example of a backend service for an e-commerce platform. It uses Node.js, Express, and MongoDB, among other technologies from the MERN ecosystem, to create a RESTful API for managing products, carts, and user authentication.

Home Page: https://thayrov-backend-dev.fl0.io/

License: MIT License

JavaScript 86.75% Handlebars 11.63% Dockerfile 0.09% CSS 1.53%
backend coderhouse ecommerce restful-api

backend's Introduction

E-Commerce Backend Project

Description

This project is an educational example of a backend service for an e-commerce platform. It uses Node.js, Express, and MongoDB, among other technologies from the MERN ecosystem, to create a RESTful API for managing products, carts, and user authentication.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/Thayrov/Backend.git
  2. Navigate to the project directory:

    cd Backend
  3. Install dependencies:

    npm install
  4. Create a .env.production or .env.development files based on the .env.example and fill in the environment variables.

  5. Run the project:

    npm start

    or

    npm run dev

Usage

After starting the server, you can use the following base URL to access the API:

http://localhost:PORT/api/

Replace PORT with the port number you specified in the .env file.

API Documentation

The API documentation is available at:

http://localhost:PORT/apidocs

Folder Structure

  • src/: Source code
    • config/: Configuration files
    • controllers/: Route controllers
    • dao/: Data access objects
    • docs/: API documentation (Swagger)
    • dto/: Data transfer objects
    • middlewares/: Custom middleware
    • routes/: API routes
    • services/: Business logic
    • views/: Views made with handlebars
  • test/: Tests code
  • .env: Environment variables (do not commit)
  • .gitignore: Confirm .env file location in here
  • package.json: Project metadata and dependencies
  • app.js: App starting file
  • README.md: This file

Environment Variables

The port number the application will listen on

PORT=

GitHub OAuth Credentials

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=

MongoDB connection string

MONGO_URL=

Secret for session storage

SESSION_SECRET=

Type of persistence storage (e.g., 'memory', 'fs', 'mongo')

PERSISTANCE=

Node environment (development or production)

NODE_ENV=

Google email for some services like sending notifications, etc.

GOOGLE_EMAIL=

Password for the Google email account

GOOGLE_PASS=

Endpoints

Views endpoints

get http://localhost:8080

get http://localhost:8080/view/products/

get http://localhost:8080/view/products/:pid

get http://localhost:8080/login

get http://localhost:8080/register

get http://localhost:8080/profile

get http://localhost:8080/admin

get http://localhost:8080/logout

Products API endpoints

post http://localhost:8080/api/products

get http://localhost:8080/api/products

get http://localhost:8080/api/products/:pid

put http://localhost:8080/api/products/:pid

delete http://localhost:8080/api/products/:pid

Carts API endpoints

post http://localhost:8080/api/carts

post http://localhost:8080/api/carts/:cid/product/:pid

post http://localhost:8080/api/carts/:cid/purchase

get http://localhost:8080/api/carts/:cid

put http://localhost:8080/api/carts/:cid

put http://localhost:8080/api/carts/:cid/products/:pid

delete http://localhost:8080/api/carts/:cid/products/:pid

delete http://localhost:8080/api/carts/:cid

Users API endpoints

post http://localhost:8080/api/users/login

post http://localhost:8080/api/users/request-password-reset

post http://localhost:8080/api/users/reset-password

post http://localhost:8080/api/users/register

post http://localhost:8080/api/users/:uid/documents

get http://localhost:8080/api/users/github

get http://localhost:8080/api/users/githubcallback

get http://localhost:8080/api/users/current

get http://localhost:8080/api/users/forgot-password

get http://localhost:8080/api/users/reset-password

get http://localhost:8080/api/users/all-users

put http://localhost:8080/api/users/premium/:uid

delete http://localhost:8080/api/users/cleanup-users

Other endpoints

get http://localhost:8080/mockingproducts

get http://localhost:8080/error

get http://localhost:8080/loggerTest

use http://localhost:8080/apidocs

get http://localhost:8080/chat

post http://localhost:8080/chat

Contribution Guidelines

Feel free to open an issue or submit a pull request if you find any bugs or have suggestions for improvements.

License

This project is licensed under the MIT License.

Acknowledgments

Big thanks to Coderhouse for providing the learning resources.

Contact

For any further questions or collaboration, feel free to get in touch via email.

backend's People

Contributors

thayrov avatar

Watchers

 avatar

backend's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.