Git Product home page Git Product logo

harshatechtrainings / nodemailer-solution Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

This Node.js project is designed to handle user signups and send verification emails using Nodemailer. Upon successful signup through the endpoint http://localhost:3000/auth/signup, a verification email containing a URL is sent to the user. The user can click on the URL to verify their account.

JavaScript 96.06% HTML 3.94%
account-verification authentication authentication-middleware email-verification email-verification-api expressjs http-endpoint middleware nodejs nodejs-nodemailer nodemailer nodemailer-smtp-transport user-signup web-development

nodemailer-solution's Introduction

Node.js Email Verification Project

Overview

This Node.js project is designed to handle user signups and send verification emails using Nodemailer. Upon successful signup through the endpoint http://localhost:3000/auth/signup, a verification email containing a URL is sent to the user. The user can click on the URL to verify their account.

Features

  • User signup endpoint (/auth/signup) for account creation.
  • Nodemailer integration to send verification emails.
  • Token-based email verification for enhanced security.

Prerequisites

Make sure you have the following installed before running the project:

  • Node.js

  • npm (Node Package Manager)

    Create a .env file with below

    PORT=<server port>
    MONGODB_URI=<mangodb cluster URL>
    JWT_SECRET=<any random secret key>
    EMAIL_SENDER=<sendermail>
    EMAIL_APPPASS=<Mail APP Passcode>

Getting Started

  1. Clone the repository:

    git clone https://github.com/yourusername/node-email-verification.git

    Copy paste the .env file created above in this project

  2. Setup Project

    npm install
  3. Start server

    node app.js

1.User Signup API Endpoint

Overview

This API endpoint is responsible for user registration and account creation. Users can sign up by sending a POST request to http://localhost:3000/auth/signup with the required information in the request body.

Endpoint Details

  • Method: POST
  • Endpoint: /auth/signup

Request

Body Parameters

  • fullname (string): The full name of the user.
  • username (string): The email address or username for the user's account.
  • password (string): The chosen password for the user's account.
  • confirmPassword (string): Confirmation of the chosen password.

Example Request Body

{
  "fullname": "String",
  "username": "String",
  "password": "String",
  "confirmPassword": "String"
}

2.User Sign-In API Endpoint

Overview

This API endpoint handles user authentication. Users can sign in by sending a POST request to http://localhost:3000/auth/signin with their username and password in the request body.

Endpoint Details

  • Method: POST
  • Endpoint: /auth/signin

Request

Body Parameters

  • username (string): The email address or username associated with the user's account.
  • password (string): The user's password.

Example Request Body

{
  "username": "string",
  "password": "string"
}

3.User Information Retrieval API Endpoint

Overview

This API endpoint allows fetching user information based on the provided username. Authentication is required through either a Bearer token or Basic Authentication.

Bearer token will be generated in response once you access the Signin.

Endpoint Details

  • Method: GET
  • Endpoint: /users/{username}

Authentication

Access to this endpoint requires authentication. You can provide authentication using either of the following methods:

Bearer Token

Include a valid Bearer token in the Authorization header:

Authorization: Bearer your_access_token

If you are using postman, go to Authorization and select the Bearer token in type.

4.User Information Update API Endpoint

Overview

This API endpoint allows updating user information based on the provided username. Authentication is required through either a Bearer token or Basic Authentication.

Endpoint Details

  • Method: PUT
  • Endpoint: /users/{username}

Authentication

Access to this endpoint requires authentication. You can provide authentication using either of the following methods:

Bearer Token

Include a valid Bearer token in the Authorization header:

Authorization: Bearer your_access_token

5.User Deletion API Endpoint

Overview

This API endpoint allows deleting a user based on the provided username. Authentication is required through either a Bearer token or Basic Authentication.

Endpoint Details

  • Method: DELETE
  • Endpoint: /users/{username}

Authentication

Access to this endpoint requires authentication. You can provide authentication using either of the following methods:

Bearer Token

Include a valid Bearer token in the Authorization header:

Authorization: Bearer your_access_token

6.All Users Retrieval API Endpoint

Overview

This API endpoint allows fetching information for all users. Authentication is required through either a Bearer token or Basic Authentication.

Endpoint Details

  • Method: GET
  • Endpoint: /users

Authentication

Access to this endpoint requires authentication. You can provide authentication using either of the following methods:

Bearer Token

Include a valid Bearer token in the Authorization header:

Authorization: Bearer your_access_token

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.