Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/surajmendhe5573/authentication

Authentication APIs
https://github.com/surajmendhe5573/authentication

authentication expressjs mongodb nodejs nodemailer rest-api

Last synced: 6 days ago
JSON representation

Authentication APIs

Awesome Lists containing this project

README

        

# User Product Management and Contact APIs

This project provides a basic API for user authentication and product management using Node.js, Express.js, and MongoDB. It includes endpoints for user sign-up, sign-in, and product operations.

## Features

- User sign-up and sign-in with JWT authentication
- Product management operations (Create and Retrieve Products)
- Send Notifications via email

# API Endpoints

## User Endpoints

### Sign Up
- **URL:** `http://localhost:6000/users/signup`
- **Method:** `POST`
- **Description:** Registers a new user.
- **Request Body:**
```json
{
"username": "string",
"email": "string",
"password": "string"
}

### Sign In

**URL:** `http://localhost:6000/users/signin`

**Method:** `POST`

**Description:** Authenticate a user and return a JWT token.

**Request Headers:**
- Content-Type: `application/json`

**Request Body:**
```json
{
"email": "string",
"password": "string"
}
```

## Product Endpoints

### Create Product

**URL:** `http://localhost:6000/products/create`

**Method:** `POST`

**Description:** Upload a new product.

**Request Headers:**
- Content-Type: `application/json`

**Request Body:**
```json
{
"name": "string",
"description": "string",
"price": "number",
"stock": "number"
}

```

### Fetch Products

**URL:** `http://localhost:6000/products/fetch`

**Method:** `GET`

**Description:** Retrieve a list of all products.

### Contact Form API
- **URL:** `http://localhost:6000/contact`
- **Method:** `POST`
- **Description:** Handles contact form submissions and sends an email with the submitted details..
**Request Body:**

The request body should be in JSON format and include the following fields:
- `name` (string): The name of the person submitting the form.
- `email` (string): The email address of the person submitting the form.
- `message` (string): The message/content of the contact form.

**Example Request:**

```json
{
"name": "John Doe",
"email": "[email protected]",
"message": "Hello, this is a test message!"
}
```
**Response:**

```json
{
"message": "Email sent successfully"
}
```

## Set Up Environment Variables

Create a `.env` file in the root directory of your project and add your environment variables. Below is an example `.env` file:

**Example `.env` file:**
```env
SecretKey=your_jwt_secret_key
MONGO_URI=mongodb://localhost:27017/defaultdb
PORT=3000
[email protected]
EMAIL_PASS=your-email-password