8000 GitHub - himacharan128/ecommerce-api: A Node.js Based Backend API application
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

himacharan128/ecommerce-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ecommerce API

This repository contains a simple Ecommerce API for managing products and variants. The API is built using Node.js, Express, and MongoDB.

Getting Started

Follow the steps below to run the project locally:

  1. Clone the repository:
git clone https://github.com/himacharan128/ecommerce-api.git
  1. Install dependencies:
cd ecommerce-api
npm install
  1. Create a .env file in the root directory and set the MongoDB connection URI:
MONGODB_URI=your_mongodb_connection_uri
  1. Start the server:
node index.js

The server will be running at http://localhost:3000.

API Documentation

Endpoints

  • POST /products: Create a new product.
  • GET /products: Get all products.
  • GET /products/:productId: Get a specific product by ID.
  • GET /products/search?query=example: Search products by name, description, or variant name.
  • PUT /products/:productId: Update a product by ID.
  • DELETE /products/:productId: Delete a product by ID.
  • POST /products/:productId/variants: Create a variant for a specific product.
  • PUT /products/:productId/variants/:variantId: Update a variant for a specific product.
  • DELETE /products/:productId/variants/:variantId: Delete a variant for a specific product.

Project Structure

  • src/controllers: Contains the controllers for handling API requests.
  • src/models: Defines the Mongoose schemas for products and variants.
  • src/routes: Defines the API routes.
  • src/tests: Contains test files (not implemented in this example).
  • index.js: Main entry point for the application.
  • .env: Environment variable configuration file .

Dependencies

  • Express: A fast, unopinionated, minimalist web framework for Node.js.
    npm install express
  • Mongoose: MongoDB object modeling tool designed to work in an asynchronous environment.
    npm install mongoose
    
  • Body-Parser: Node.js body parsing middleware to parse incoming request bodies.
    npm install body-parser
    
  • Dotenv: Zero-dependency module that loads environment variables from a .env file.
    npm install dotenv

Contributing

Contributions are welcome! If you have any ideas for improvement or would like to report an issue, please open an issue or submit a pull request.

About

A Node.js Based Backend API application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0