An open API service indexing awesome lists of open source software.

https://github.com/jeevan42/post-it-blog-app-backend

๐Ÿ” Backend Repo for a MERN blog app with JWT-based user authentication, bcrypt password hashing, and full CRUD API for blog posts using Node.js, Express, and MongoDB.
https://github.com/jeevan42/post-it-blog-app-backend

backend bcrypt blog-api crud-api express jwt-authentication mern-stack mongodb nodejs rest-api

Last synced: 2 months ago
JSON representation

๐Ÿ” Backend Repo for a MERN blog app with JWT-based user authentication, bcrypt password hashing, and full CRUD API for blog posts using Node.js, Express, and MongoDB.

Awesome Lists containing this project

README

          

# ๐Ÿง  Post-It Blog App - Backend

This is the backend Repo for the **Post-It Blog App**, a full-stack blogging application built with the MERN stack. It handles user authentication using JWT, password hashing with bcrypt, and CRUD operations for blog posts.

## ๐Ÿ› ๏ธ Tech Stack
- Node.js
- Express.js
- MongoDB (Mongoose)
- JWT Authentication
- Bcrypt for password hashing

## ๐Ÿ“ฆ Features
- User registration and login
- JWT-based authentication
- CRUD operations on blog posts (Create, Read, Update, Delete)
- Authorization: Only post authors can update or delete their posts

## ๐Ÿ“ API Routes

### ๐Ÿ” Auth Routes
- `POST /api/register` - Register a new user
- `POST /api/login` - Log in and receive a JWT token

### ๐Ÿ“„ Blog Post Routes
- `GET /api/posts` - Get all blog posts
- `POST /api/posts` - Create a new blog post (Protected)
- `PUT /api/posts/:id` - Update a blog post (Protected)
- `DELETE /api/posts/:id` - Delete a blog post (Protected)

## ๐Ÿงช Tools & Libraries
- `dotenv` - Environment variable management
- `jsonwebtoken` - Token-based authentication
- `bcrypt` - Secure password hashing
- `cors` - Cross-origin resource sharing
- `mongoose` - MongoDB object modeling

## ๐Ÿ“ Folder Structure


post-it-blog-app-backend/
โ”œโ”€โ”€ controllers/
โ”‚ โ”œโ”€โ”€ auth.controller.js
โ”‚ โ””โ”€โ”€ post.controller.js
โ”œโ”€โ”€ models/
โ”‚ โ”œโ”€โ”€ User.js
โ”‚ โ””โ”€โ”€ Post.js
โ”œโ”€โ”€ routes/
โ”‚ โ”œโ”€โ”€ auth.js
โ”‚ โ””โ”€โ”€ posts.js
โ”œโ”€โ”€ middleware/
โ”‚ โ””โ”€โ”€ auth.js
โ”œโ”€โ”€ config/
โ”‚ โ””โ”€โ”€ db.js
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ server.js

## ๐Ÿ“ Setup Instructions
```bash
git clone https://github.com/jeevan42/post-it-blog-app-backend
cd post-it-blog-app-backend
npm install
# Add .env file with your MongoDB URI and JWT_SECRET
npm start
```

## ๐Ÿ™Œ Contributing
PRs and stars are welcome. For major changes, open an issue first to discuss what you would like to change.