Backend App using Node.js, Express, MongoDB, and JWT

Hira Saleem

Overview

CodeCraftHub is a backend application that provides user authentication and profile management APIs using Node.js, Express, MongoDB, and JWT.

Features

User registration with hashed passwords
User authentication with JWT token
Update user profile by email or username
Secure password handling using bcrypt

Installation

Clone the repository:
git clone https://github.com/HSk2703/CodeCraftHub.git
cd CodeCraftHub
Install dependencies:
npm install
Create a .env file and configure environment variables:
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key

Start the server:
npm start 
OR
node server.js

API Endpoints

User Routes

Register a new user
Endpoint: POST /register
Request Body:
{
"name": "John Doe",
"email": "johndoe@example.com",
"password": "securepassword"
}
Response:
{
"message": "User registered successfully",
"user": { "id": "123", "name": "John Doe", "email": "johndoe@example.com" }
}
User Login
Endpoint: POST /login
Request Body:
{
"email": "johndoe@example.com",
"password": "securepassword"
}
Response:
{
"message": "Login successful",
"token": "your_jwt_token"
}
Update User by Email
Endpoint: PUT /update
Request Body:
{
"email": "johndoe@example.com",
"name": "John Smith",
"password": "newpassword"
}
Response:
{
"message": "Profile updated successfully",
"user": { "id": "123", "name": "John Smith", "email": "johndoe@example.com" }
}
Update User by Username
Endpoint: PUT /:username
Request Body:
{
"newUsername": "john_smith",
"email": "john_smith@example.com"
}
Response:
{
"message": "Profile updated successfully",
"user": { "id": "123", "name": "john_smith", "email": "john_smith@example.com" }
}

Technologies Used

Node.js
Express.js
MongoDB
bcrypt.js
jsonwebtoken
Like this project
0

Posted Feb 18, 2025

CodeCraftHub is a backend application that provides user authentication and profile management APIs using Node.js, Express, MongoDB, and JWT.

AI-Powered Chatbot
AI-Powered Chatbot
Django-Car-Dealership-App
Django-Car-Dealership-App
Shopify-Powered Women's Fashion E-commerce Store
Shopify-Powered Women's Fashion E-commerce Store
Shopify-Powered Women's Fashion Boutique
Shopify-Powered Women's Fashion Boutique