xonoxc / express.backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User Authentication Backend with Node.js and Mogogo DB

This is a user authentication backend built using Node.js and Mogogo DB. It provides secure authentication and user management features for your application.

Table of Contents

  1. Features
  2. Getting Started
  3. Configuration
  4. Usage
  5. API Endpoints

Features

  • User registration with email verification.
  • User login with JWT (JSON Web Tokens) authentication.
  • Password reset functionality.
  • Secure password hashing.
  • Role-based access control.
  • MongoDB integration.

Getting Started

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Node.js installed. Download it from nodejs.org.
  • Mogogo DB or MongoDB installed and running. You can get it from mongodb.com.

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/express.backend.git
    cd express.backend
    
  2. Install dependencies:

    npm install
  3. Create a .env file in the project root and configure your environment variables (see Configuration).

  4. Start the server:

    1. to start server without nodemon
    npm start
    
    1. to start a server with nodemon
    npm run dev
    

Your authentication backend should now be running on http://localhost:4000.

Configuration

You need to set up your environment variables in a .env file in the project root. Here's an example .env file:

PORT=3000
MONGODB_URI=mongodb://localhost:27017/mogogodb
JWT_SECRET=mysecretkey
EMAIL_SENDER=email@example.com
EMAIL_PASSWORD=email_password

Make sure to replace the placeholder values with your actual configuration.

Usage

API Endpoints

This backend provides the following API endpoints:

  • POST /users/register - Register a new user.
  • GET /users - get all the users in the database.
  • GET /users/:username - get a perticular user based on userame

You can explore these endpoints using a tool like Postman or integrate them into your frontend application.

About


Languages

Language:JavaScript 100.0%