https://github.com/guptag0808/product_management
This is a simple API for managing products and product categories built using Node.js, Express, Sequelize , mysql2.
https://github.com/guptag0808/product_management
bcrypt express expressjs jwt-authentication mysql2 sequelize
Last synced: 3 months ago
JSON representation
This is a simple API for managing products and product categories built using Node.js, Express, Sequelize , mysql2.
- Host: GitHub
- URL: https://github.com/guptag0808/product_management
- Owner: guptag0808
- Created: 2024-02-24T12:02:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-25T05:42:18.000Z (over 1 year ago)
- Last Synced: 2025-02-08T19:33:29.840Z (4 months ago)
- Topics: bcrypt, express, expressjs, jwt-authentication, mysql2, sequelize
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Product Management API
This is a simple API for managing products and product categories built using Node.js, Express, Sequelize , mysql2.
## Table of Contents
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Authentication](#authentication)
- [Endpoints](#endpoints)
- [API Reference](#api-reference)
- [Contributing](#contributing)
- [License](#license)## Getting Started
### Prerequisites
Make sure you have the following installed on your machine:
- [Node.js](https://nodejs.org/)
- [npm](https://www.npmjs.com/) (Node Package Manager)
- [MySQL](https://www.mysql.com/) or any other relational database supported by Sequelize### Installation
1. Clone the repository:
```bash
git clone https://github.com/your-username/product-management-api.git## nstall dependencies:
cd product-management-api
npm install
## Usage## User Schema
- **Endpoint:** `/user/register`
- **Method:** `POST`
- **Request Body:**```json
{
"username":"Raj",
"email":"[email protected]",
"password":"raj"
}- **Endpoint:** `/user/login`
- **Method:** `POST`
- **Request Body:**```json
{
"email":"[email protected]",
"password":"raj"
}
- **Endpoint:** `/product/create`
- **Method:** `POST`
- **Request Body:**```json
{
"itemName":"sharee",
"itemCode":"abc121",
"itemType":"clothes"
}### Authentication
- All routes except for the POST /user/register and POST /user/login routes are protected and require authentication. You need to include a valid JSON Web Token (JWT) in the Authorization header of your requests.# Endpoints
- POST /auth/register: Register a new user.
- POST /auth/login: Log in and receive a JWT.
- POST /products/create: Add a new product (Protected Route).
- GET /products: Get all products.
- GET /products/:id: Get product by ID.
- PUT /products/:id: Update product by ID (Protected Route).
- DELETE /products/:id: Delete product by ID (Protected Route).
- GET /products/category/:categoryId: Get products by category.
- GET /products/name/:productName: Get products by name.