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.
- Installation
- Usage
- API Documentation
- Folder Structure
- Environment Variables
- Endpoints
- License
- Acknowledgments
- Contact
-
Clone the repository:
git clone https://github.com/Thayrov/Backend.git
-
Navigate to the project directory:
cd Backend
-
Install dependencies:
npm install
-
Create a
.env.production
or.env.development
files based on the.env.example
and fill in the environment variables. -
Run the project:
npm start
or
npm run dev
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.
The API documentation is available at:
http://localhost:PORT/apidocs
src/
: Source codeconfig/
: Configuration filescontrollers/
: Route controllersdao/
: Data access objectsdocs/
: API documentation (Swagger)dto/
: Data transfer objectsmiddlewares/
: Custom middlewareroutes/
: API routesservices/
: Business logicviews/
: Views made with handlebars
test/
: Tests code.env
: Environment variables (do not commit).gitignore
: Confirm .env file location in herepackage.json
: Project metadata and dependenciesapp.js
: App starting fileREADME.md
: This file
PORT=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=
MONGO_URL=
SESSION_SECRET=
PERSISTANCE=
NODE_ENV=
GOOGLE_EMAIL=
GOOGLE_PASS=
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
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
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
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
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
Feel free to open an issue or submit a pull request if you find any bugs or have suggestions for improvements.
This project is licensed under the MIT License.
Big thanks to Coderhouse for providing the learning resources.
For any further questions or collaboration, feel free to get in touch via email.