Git Product home page Git Product logo

user-authentication-node.js-express.js's Introduction

User-Authentication-Node.js-Express.js

User Authentication REST API built using Node & Express. The REST API include User Login, User Register, Reset Password, storing Email Subscribers, Automatic emails & etc. You just simply clone the Repo, add your Database link, add your API keys, customise the API according to your requirements and start using the Rest API.

Functionalities & Features

  • Login
  • Register
  • Reset Password
  • Logout
  • Email Subscriptions
  • Automatic email on Register or Login

Getting Started

Below you can find the process of installation, prerequisites and more so you can get these User Authentication functionality developed in the matter of minutes.

Prerequisites

Install the latest version of npm

npm install npm@latest -g

Create a MongoDB Database (optional - or use Robo3T)

Create a SendGrid API Key

Installation

  1. Clone the repo

    git clone https://github.com/Rajsuthan/User-Authentication-Node.js-Express.js
  2. Install NPM packages

    npm install
  3. Update your Databse url in .env

    DATABASE='ENTER YOUR DB URL'
  4. Update your SendGrid API key in .env

    SENDGRID_API_KEY='ENTER YOUR SENDGRID API KEY'
  5. Add your SendGrid email in emailsubscriber.js

      exports.sendGridEmailResetPassword = (email, subject, message, code) => {
        sgMail.setApiKey(process.env.SENDGRID_API_KEY);
        const msg = {
          to: email,
          from: "[email protected]", // Please use your Sendgrid email
          subject: subject,
          text: `${message}\n\n This is your verification code: ${code}`,
        };
        sgMail
          .send(msg)
          .then(() => {
            console.log("Email sent");
          })
          .catch((error) => {
            console.error(error);
          });
    };
       ```
  6. Start the server

    npm start

Environment variables

These environment variables will be used for configuring different services by default:

Key Default Value Description
DATABASE url MongoDB Cluster URL
SECRET value Used for Creating unique tokens
API_KEY key API Key for your Endpoint (can be anything)
SENDGRID_API_KEY key Sendgrid API Key (for sending emails)

Routes

URL Method Description Content (Body)
/api/signup POST Registers a user and sends email verification firstname lastname email password
/api/signin POST Login with existing user email password
/api/sendverificationcode PUT Send Verification code to change password email
/api/resetpassword PUT Changes User's Password id verificationCode newPassword
/api/signout GET Signs out a User None
/api/user/:userId GET Retrieve the Single User None
/api/user/:userId PUT Updates the Single User and returns user name email password
/api/user/:userId DELETE Deletes the Single User None
/api/users/:userId GET Get all Users(only admin) None
/api/emailsubscriber POST Add the Email in the DB email
/api/emailsubscribers/:userId GET Get all Email Subscribers (only admin) None

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Rajsuthan Gopinath - @rajsuthan_dev - [email protected]

Portfolio - https://raj-dev.netlify.app/

Project Link: https://github.com/Rajsuthan/User-Authentication-Node.js-Express.js

user-authentication-node.js-express.js's People

Contributors

rajsuthan avatar rajsuthang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.