Coder Social home page Coder Social logo

mburuxx / authentication-api Goto Github PK

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

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: MIT License

JavaScript 100.00%
express mongodb nodejs

authentication-api's Introduction

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

authentication-api's People

Contributors

mburuxx avatar

Stargazers

 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.