GithubHelp home page GithubHelp logo

restful-api's Introduction

User Registration and Profile API

This project implements a RESTful API for user registration, login, password change, and profile retrieval using Node.js, Express, MongoDB, and JWT authentication.

Features

  • User registration: Users can register an account with a username, email, and password. An email confirmation is sent upon registration.
  • User login: Registered users can log in using their username and password and receive an access token.
  • Password change: Users can change their password by providing their old password and new password.
  • Profile retrieval: Users can retrieve their personal information, including username and email.

Prerequisites

Before running the project, make sure you have the following prerequisites installed:

  • Node.js (v12 or higher)
  • MongoDB
  • NPM or Yarn (package managers)

Installation

  1. Clone the repository:
git clone <repository-url>
  1. Install the dependencies:
cd user-registration-api
npm install
  1. Configure environment variables:

Create a .env file in the project root directory and provide the necessary environment variables. Here's an example:

MONGODB_URI=<your-mongodb-connection-string>
JWT_SECRET=<your-jwt-secret>
EMAIL_USER=<your-email-username>
EMAIL_PASSWORD=<your-email-password>
  1. Start the server:
npm run dev

The server should start running on http://localhost:3000.

Usage

You can use tools like Insomnia or Postman to interact with the API endpoints.

User Registration

  • Endpoint: POST /api/register
  • Headers: Content-Type: application/json
  • Request Body Example:
    {
      "username": "john_doe",
      "email": "[email protected]",
      "password": "password123"
    }

User Login

  • Endpoint: POST /api/login
  • Headers: Content-Type: application/json
  • Request Body Example:
    {
      "username": "john_doe",
      "password": "password123"
    }

Password Change

  • Endpoint: POST /api/actions/changepassword
  • Headers: Content-Type: application/json, Authorization: Bearer YOUR_TOKEN
  • Request Body Example:
    {
      "old_password": "old-password",
      "new_password": "new-password"
    }

Profile Retrieval

  • Endpoint: GET /api/profiles
  • Headers: Content-Type: application/json, Authorization: Bearer YOUR_TOKEN

Contributing

Contributions to this project are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

restful-api's People

Contributors

saabdulle avatar dependabot[bot] 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.