Skip to content

Authentication API is a Node.js solution for user registration and authentication. Designed to be easily integrated into any application that uses HTTP, it leverages JWT for secure authentication. This API provides endpoints for user registration and login, ensuring secure and efficient user management.

License

Notifications You must be signed in to change notification settings

mburuxx/authentication-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Authentication API

This is a user authentication API built with Node.js that can be used in any application that uses HTTP.
It provides endpoints for user registration, login, and token generation.
The API uses JWT for authentication and supports middleware for handling authentication and errors.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/user-authentication-api.git

  2. Navigate to the project directory:

    cd authentication-api

  3. Install dependencies:

    npm install

    Alternatively, you can install dependencies listed in requirements.txt:

    npm install $(cat requirements.txt | xargs)

Configuration

  • config/db.js: Contains database connection logic.

Database

Ensure you have MongoDB installed and running. Configure the database connection in config/db.js.

Models

  • models/userModel.js: Defines the User schema and model.

Controllers

  • controllers/userController.js: Contains logic for user registration and login.

Middleware

  • middleware/authMiddleware.js: Middleware to protect routes that require authentication.
  • middleware/errorMiddleware.js: Middleware for error handling.

Routes

  • routes/userRoutes.js: Defines the user-related routes (registration, login).

Utils

  • utils/generateTokens.js: Contains functions for generating JWT tokens.

Server

  • server.js: Entry point for the API. Configures and starts the server.

Environment Variables

Create a .env file in the root of your project with the following environment variables:

PORT=5000
MONGO_URI=your_mongo_db_uri
JWT_SECRET=your_jwt_secret

About

Authentication API is a Node.js solution for user registration and authentication. Designed to be easily integrated into any application that uses HTTP, it leverages JWT for secure authentication. This API provides endpoints for user registration and login, ensuring secure and efficient user management.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published