This project is a full-stack blog application featuring 🧑💻 authentication, 📝 post management, and a 🔒 protected route system. The backend is built with Node.js 🟢 and SQLite 🗄️, while the frontend uses React ⚛️ and TailwindCSS 🎨.
- 🆕 User Registration and Login with 🔑 JWT-based Authentication.
- ✏️ Create, 📖 Read, ✂️ Update, and ❌ Delete (CRUD) functionality for blog posts.
- 📄 Pagination and 🔄 sorting for blog posts.
- 🔒 Secure backend using 🛡️ middleware for authentication and validation.
- 🚪 Protected routes to restrict access to authenticated users.
- ⚡ Cache optimization using
localStoragefor frontend performance. - 🖌️ Styled with TailwindCSS for a responsive and modern design.
- Node.js 🟢 with Express 🚀
- SQLite 🗄️ using better-sqlite3 for database management
- jsonwebtoken 🔑 for token-based authentication
- bcrypt 🔒 for password hashing
- dotenv 🛠️ for environment configuration
- React ⚛️ with React Router 🗺️
- React Paginate 🔄 for pagination
- TailwindCSS 🎨 for styling
- Node.js 🟢 installed
- SQLite database file created
- Clone the repository:
git clone https://github.com/FoxerBN/your-repo.git
- Navigate to the backend directory:
cd backend - Install dependencies:
npm install
- Create a
.envfile and add the following:JWT_SECRET=your-secret-key
- Start the backend server:
nodemon index.js
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install
- Start the development server:
npm run dev
POST /user/register- 🆕 Register a new userPOST /user/login- 🔑 Login a user and set JWT tokenPOST /user/logout- 🚪 Logout user by clearing tokenGET /user/auth-check- ✔️ Verify if user is authenticated
GET /posts/page?page={page}&order={order}- 📄 Fetch paginated and sorted postsPOST /posts/create- ✏️ Create a new postDELETE /posts/delete/{id}- ❌ Delete a post by IDGET /posts/{id}- 📋 Get post details by ID
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
password TEXT NOT NULL
);CREATE TABLE IF NOT EXISTS posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT NOT NULL,
author TEXT NOT NULL,
date TEXT NOT NULL
);project-root
├── src
│ ├── backend
│ │ ├── config
│ │ ├── routes
| | ├── controllers
| | ├── middlewares
| | ├── functions
│ │ └── index.js
│ ├── frontend
│ │ ├── components
│ │ ├── pages
│ │ ├── App.jsx
│ │ ├── api.js
│ │ └── ProtectedRoute.jsx
├── README.md
└── package.json
- Navigate to
/authto register or log in. 🔑 - After logging in, you'll be redirected to the main page. 📄
- Create, view, and delete posts as needed. 📝
- Use the pagination controls to navigate through posts. 🔄
- Email: 📧 barspin4499@gmail.com
- GitHub: 🐱 FoxerBN