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

Hira Saleem

0

Backend Engineer

Fullstack Engineer

AI Developer

ExpressJS

JavaScript

Node.js

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

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

Likes

0

Views

1

Tags

Backend Engineer

Fullstack Engineer

AI Developer

ExpressJS

JavaScript

Node.js

Hira Saleem

Certified Fullstack Software Dev|Shopify|Blockchain & Web3

AI-Powered Chatbot
AI-Powered Chatbot
🚗 Car Dealership Web Application Development
🚗 Car Dealership Web Application Development
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