
Project Name
Blog PlatformTechnologies
Express.js, MySQL, Node jsVersion (original build)
Node - 22.3.0,Express - 4.21.2
Technologies
Overview
This platform is designed to provide a seamless experience for content creators, administrators, and readers alike, enabling efficient content creation, management, and engagement.
Key Features
- Dashboard Overview – Displays recent blogs, user stats, and content counts.
- Content Management – Create, edit, and organize blogs with categories, tags, and author details.
- Search Functionality – Allows users to find blogs easily based on keywords, tags, or categories.
- Subscription System – Notifies users via email when a new blog is published.
- Portfolio Updates – Update and test the portfolios.
What We Have Done
We have built this project from scratch using Node.js and Express.js, incorporating the above features to ensure an organized and user-friendly content management system. The comprehensive set of functionalities demonstrates the platform's versatility and commitment to delivering a powerful blogging experience for both administrators and readers
Admin Panel Features
- Dashboard – Displays recent blogs, user statistics, and the total counts of tags, categories, users, and blogs.
- User Management – Allows administrators to create, update, and manage users.
- Country Management – Enables the creation and management of countries along with their respective country codes.
- State Management – Allows adding and managing states linked to specific countries.
- Tag Management – Facilitates the creation and organization of multiple tags for better content classification.
- Category Management – Helps in structuring blogs by organizing them into relevant categories.
- Blog Management – Allows administrators to create, edit, and delete blog posts.
- Tag Assignment – Enables assigning multiple tags to a blog for improved search and filtering.
- Category and Author Assignment – Ensures each blog is assigned a relevant category and an author for better organization.
User-Side Features
- Home Page – Displaying recently added blogs, tags, and categories.
- Search Functionality – For quickly finding blog posts by title and content.
- Tag-Based and Category-Based Browsing – For organized content discovery.
- Subscription System – With email notifications for new blog posts.
- Blog Listing and Details Pages – Showcasing complete blog content with search, filter, and pagination.
- Author Profiles – Displaying individual authors' published blogs.
- Contact and About Pages – For inquiries and platform information.
- Email Notification System – To keep subscribers informed.
Code Snippets
Code snippet 1
- This code defines an asynchronous sendEmail function that uses Nodemailer to send emails. The function accepts parameters for the recipient's email, subject, text, and HTML content. It creates a transporter using environment variables like MAILPIT_HOST, MAILPIT_PORT, and MAILPIT_SECURE for secure and flexible configuration. The mailOptions object defines the email's sender, recipient, subject, and content. The await transporter.sendMail(mailOptions) method is used to send the email, ensuring the process is completed before proceeding. Errors are handled gracefully using a try-catch block, providing clear error messages for troubleshooting. This approach ensures secure, reusable, and efficient email delivery.
Code snippet 2
- This code snippet configures Passport.js with the LocalStrategy for user authentication. The strategy is designed to validate a user's credentials based on a provided username and password. The passport.use() method initializes the LocalStrategy, specifying usernameField and passwordField to identify the expected input fields for the username and password. Inside the async callback, the code attempts to find a user in the database using User.findOne({ where: { username } }). If no user is found, it invokes done() with null and false, indicating authentication failure with an error message: "Incorrect username.". If the user exists, the code compares the provided password with the stored hashed password using bcrypt.compare(). If the passwords don't match, it again calls done() with null and false, along with the message: "Incorrect password.". Finally, if both the username and password are correct, the done() function is called with null and the user object, confirming successful authentication. This implementation ensures secure login functionality by efficiently handling errors and providing clear feedback during authentication attempts.