This project is a backend of PW blog web application built using the MERN (MongoDB, Express.js, React.js, Node.js) stack. The application allows users to create, read, update, and delete blog posts. Users can also register, log in, and manage their own blog posts securely.
- User registration and authentication.
- Create and explore the lists of blogs.
- Explore blogs created by other users.
- View detailed information for each blog post.
- Update and Delete the lists of blogs created by yourself.
Check out the live demo of the PW Blogs application here: PW Blogs Demo
- Clone the repository:
git clone https://github.com/vishal-kumaar/pw-blog-backend
- Navigate to the project directory:
cd pw-blog-backend
- Install dependencies:
npm install
- Create a
.env
file in this project's root directory with the keys and values as follow.PORT=enterPort; MONGODB_URI=enterMongoURI JWT_SECRET=enterJwtSecret JWT_EXPIRY=enterJwtExpiry ALLOWED_ORIGINS=AllowedOriginsSepreatedByComma
- Start the server:
npm start
- Open your web browser and visit:
http://localhost:${yourPort}
- Register for a new account or log in if you already have one.
- Explore and create your lists of blogs.
- Share your blogs with friends and get inspired by theirs!
These are the API endpoints with their descriptions.
-
POST /api/user/register
: To register new user. -
POST /api/user/login
: To login already existing user. -
POST /api/blog/add
: To add a new blog.
Note: It requires authentication header with token. -
GET /api/blog
: To get list of all the blogs. -
GET /api/myblog
: To get list of all the blogs related to the user.
Note: It requires authentication header with token. -
GET /api/blog/:blogId
: To get blog data for specific blog id. -
PATCH /api/blog/:blogId
: To update a specific blog by blog id.
Note: It requires authentication header with token. -
DELETE /api/blog/:blogId
: To delete a specific blog by blog id.
Note: It requires authentication header with token.
- Express.js - Backend web framework.
- MongoDB - Database for storing user and blog data.
- Mongoose - Object Data Modeling (ODM) library for MongoDB.
- Bcrypt.js - Library for hashing and salting passwords.
- Cors - Middleware for enabling CORS (Cross-Origin Resource Sharing).
- Dotenv - Environment variable management.
- Jsonwebtoken - Library for generating and validating JSON Web Tokens (JWT).
- Morgan - HTTP request logger middleware for Node.js.
- Nodemon - Development tool for automatically restarting Node.js applications upon file changes during development.
We warmly welcome contributions from the community! If you wish to contribute to the PW Blog app or find any issues, please don't hesitate to raise them.
Feel free to customize this template to fit your project's specific needs. A well-crafted README.md file can help users understand your project better, encourage contributions, and showcase your work effectively. Happy coding!
- Linkedin :- https://www.linkedin.com/in/vishal-kumar-909758228/
- Gmail :- vishal.kumar08376@gmail.com