<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Josh Endemann</title>
    <description>The latest articles on DEV Community by Josh Endemann (@jahend412).</description>
    <link>https://dev.to/jahend412</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2261789%2Fec40ca67-0428-4b87-9b07-fa654c65b94a.png</url>
      <title>DEV Community: Josh Endemann</title>
      <link>https://dev.to/jahend412</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jahend412"/>
    <language>en</language>
    <item>
      <title>Delving Back Into React: Building a Website for a Local Construction Company</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Sun, 22 Dec 2024 23:51:37 +0000</pubDate>
      <link>https://dev.to/jahend412/delving-back-into-react-building-a-website-for-a-local-construction-company-4pkh</link>
      <guid>https://dev.to/jahend412/delving-back-into-react-building-a-website-for-a-local-construction-company-4pkh</guid>
      <description>&lt;p&gt;After a brief hiatus from working with React, I decided to dive back into it. Originally, I planned to start with Next.js, as it's the modern framework everyone’s talking about. However, I realized that jumping straight into it might be overwhelming since I hadn’t worked with React in a while. Instead, I opted for a refresher by building a project in vanilla React—and what better way to do that than to solve a real-world problem?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Project: A Website for Down to Earth Contractors
&lt;/h2&gt;

&lt;p&gt;A local construction company was in need of a modern website to showcase their services, highlight past projects, and provide a way for potential clients to get in touch. This seemed like the perfect opportunity to brush up on my React skills while creating something meaningful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features of the Website
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Responsive Design
&lt;/h4&gt;

&lt;p&gt;The website is fully responsive, ensuring an optimal user experience on desktops, tablets, and mobile devices.&lt;/p&gt;

&lt;h4&gt;
  
  
  Dynamic Content
&lt;/h4&gt;

&lt;p&gt;Each service—excavation, grading, demolition, and more—has its own dedicated page with descriptive content and imagery.&lt;/p&gt;

&lt;h4&gt;
  
  
  Contact Form with EmailJS
&lt;/h4&gt;

&lt;p&gt;This was my first time integrating EmailJS into a project. The contact form allows users to submit inquiries, which are sent directly to the company’s email. Setting this up was a learning curve, but it was satisfying to see it work seamlessly.&lt;/p&gt;

&lt;h2&gt;
  
  
  A React Refresher
&lt;/h2&gt;

&lt;p&gt;Working on this website was a great way to revisit fundamental React concepts. I extensively used the &lt;code&gt;useState&lt;/code&gt; hook for managing form data and displaying dynamic status messages. Structuring the components, managing props, and styling with CSS were all valuable exercises that reminded me why I enjoy working with React.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Process of Building
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Planning and Structure
&lt;/h3&gt;

&lt;p&gt;I started by outlining the site’s structure: a homepage, a services section with individual pages, a gallery, and a contact page. Breaking the project into smaller components helped me stay organized and focus on one feature at a time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenges and Solutions
&lt;/h3&gt;

&lt;h4&gt;
  
  
  EmailJS Integration
&lt;/h4&gt;

&lt;p&gt;Setting up EmailJS was new territory for me. Understanding how to configure the service with my project required some trial and error, but the result was worth the effort. It’s exciting to see how easy it is to integrate third-party tools into a React application.&lt;/p&gt;

&lt;h4&gt;
  
  
  Styling the Navbar
&lt;/h4&gt;

&lt;p&gt;Ensuring the navbar was responsive and intuitive across devices took some tweaking. I learned more about CSS and how to use conditional class names effectively in React.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enjoying the Journey
&lt;/h2&gt;

&lt;p&gt;The process of building this website reminded me how much I love learning by doing. There’s something addictive about solving problems, seeing the results of your work, and knowing that you’re creating something valuable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Looking Ahead
&lt;/h2&gt;

&lt;p&gt;This project has rekindled my passion for React. Moving forward, I’m excited to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rebuild My Portfolio Website&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
My current portfolio is outdated, and I’m eager to create something that better reflects my skills and projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learn More React Fundamentals&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
While this project was a great refresher, there’s always more to learn. I’m planning to dive deeper into state management, performance optimization, and testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Experiment with Next.js&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Once I’m more comfortable with React again, I’ll tackle Next.js to explore server-side rendering and other advanced features.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building the Down to Earth Contractors website has been a rewarding experience. It’s a reminder that practical projects are the best way to learn and grow as a developer. If you’d like to check out the code for this project, feel free to visit the repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository&lt;/strong&gt;: &lt;a href="https://github.com/jahend412/dte-contractors" rel="noopener noreferrer"&gt;Down to Earth Contractors Website&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Building a Band Website: Navigating the Backend Challenges with Roles and Permissions</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Mon, 16 Dec 2024 03:06:01 +0000</pubDate>
      <link>https://dev.to/jahend412/building-a-band-website-navigating-the-backend-challenges-with-roles-and-permissions-4dg1</link>
      <guid>https://dev.to/jahend412/building-a-band-website-navigating-the-backend-challenges-with-roles-and-permissions-4dg1</guid>
      <description>&lt;p&gt;Building the backend for my band's website has been an exciting, challenging, and deeply educational process. Along the way, I’ve tackled a variety of issues—from setting up the comment section to refining the role-based permissions system. In this blog post, I’ll walk you through some of the hurdles I faced, how I solved them, and the valuable learning experiences that came out of the process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Comment Controller, Route, and Model
&lt;/h2&gt;

&lt;p&gt;The first challenge I ran into was setting up the comment system, which would allow users to make comments and reply to others. As we all know, handling user interactions like comments can get complicated quickly, especially when trying to build a scalable and clean solution.&lt;/p&gt;

&lt;p&gt;Here’s what I did:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comment Model&lt;/strong&gt;: I started by defining the comment schema in MongoDB using Mongoose. Each comment has an associated user, content, and timestamp. For replies, I used a reference to the parent comment, allowing users to have nested conversations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comment Controller&lt;/strong&gt;: I created functions for adding, deleting, and replying to comments. One issue I encountered was ensuring that the correct user could only edit or delete their comments. This required setting up strict checks in the controller and making sure the API routes were protected with authentication and authorization logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comment Route&lt;/strong&gt;: Once the controller was working, I set up routes that allowed users to post new comments, reply to existing ones, and delete comments. The routing required validation and error handling to ensure that users didn’t perform actions they weren’t authorized to do.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Troubleshooting involved several rounds of testing to get the comment threading functionality right. Specifically, handling nested replies and ensuring that users couldn’t delete comments they didn’t own took some time. However, after working through these edge cases, I was able to provide a clean commenting experience for the users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ensuring Routes Work Seamlessly
&lt;/h2&gt;

&lt;p&gt;After getting the comment functionality working, I turned my attention to the other routes for user management, album creation, and more. One of the key challenges was making sure all the routes were protected correctly, particularly ensuring that only authorized users could access specific resources.&lt;/p&gt;

&lt;p&gt;This is where I introduced role-based access control (RBAC) through the &lt;code&gt;checkPermissions&lt;/code&gt; middleware. By implementing this middleware, I could easily enforce permissions for different types of users (e.g., admins, fans, or band members). This also required thorough testing to ensure that the routes were working as expected and that the roles were being checked correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roles and Permissions
&lt;/h2&gt;

&lt;p&gt;Roles and permissions were the real challenge, but also the most rewarding. Initially, I was planning on having separate controllers for &lt;strong&gt;fans&lt;/strong&gt; and &lt;strong&gt;band members&lt;/strong&gt;—one for each type of user with their own set of logic. However, I reached out to the &lt;strong&gt;Node.js Slack group&lt;/strong&gt; to get some advice, and the community suggested an alternative approach: use &lt;strong&gt;roles and permissions&lt;/strong&gt; to handle access control in a more unified and scalable way.&lt;/p&gt;

&lt;p&gt;This insight was a game-changer. Instead of writing separate controllers, I could create one set of routes and use middleware to enforce different permissions based on the user’s role. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Admins could manage users, assign roles, and access analytics.&lt;/li&gt;
&lt;li&gt;Band members could create and edit their own albums and tracks.&lt;/li&gt;
&lt;li&gt;Fans had the ability to interact with the content (like, comment, etc.) but had no administrative privileges.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this approach, I was able to consolidate the logic for managing users and their actions into a single set of routes, making the code cleaner and more maintainable. The permissions were tied to each user’s role, and the middleware made sure that each action was properly authorized.&lt;/p&gt;

&lt;p&gt;The system was flexible enough to allow for detailed control over each user’s abilities, and I had to debug several issues around ensuring that the middleware was properly intercepting requests and checking the user’s permissions. The solution involved structuring the code in a way that each route, depending on the action, would be checked against the user’s roles and permissions.&lt;/p&gt;

&lt;p&gt;Once everything was set up, I was able to have clear control over who could do what—whether it was adding content, managing users, or simply commenting.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next? Moving Forward
&lt;/h2&gt;

&lt;p&gt;With the backend now mostly functional, I’m moving on to working on the &lt;strong&gt;favorites controller&lt;/strong&gt; and &lt;strong&gt;rating controller&lt;/strong&gt;. Once these are complete, I’ll start building the frontend for the website. It’s been a journey full of problem-solving and a lot of learning along the way.&lt;/p&gt;

&lt;p&gt;I’ll admit, the backend for this website might be overkill for the scope of the project, but it’s been a great opportunity to dive deep into backend development and understand how robust systems can be built with the MERN stack. I’m excited to move forward with the frontend and begin the next chapter of this project.&lt;/p&gt;

&lt;p&gt;Building this website has been incredibly fun and rewarding, and I’m looking forward to seeing how it all comes together in the end!&lt;/p&gt;




&lt;p&gt;This post was a journey through my process of solving backend challenges. If you’re working on a similar project or are considering building a web app with user authentication, role-based access, and more, I hope this gives you some insight into the problem-solving mindset needed to tackle these issues. Stay tuned for updates on the frontend development!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My Journey Through Modeling Data and Advanced Mongoose: Lessons Learned</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Tue, 10 Dec 2024 01:19:04 +0000</pubDate>
      <link>https://dev.to/jahend412/my-journey-through-modeling-data-and-advanced-mongoose-lessons-learned-1if0</link>
      <guid>https://dev.to/jahend412/my-journey-through-modeling-data-and-advanced-mongoose-lessons-learned-1if0</guid>
      <description>&lt;p&gt;I'm always excited to build my skills and grow my understanding of how backend development works. Recently, I completed the &lt;strong&gt;Modeling Data and Advanced Mongoose&lt;/strong&gt; section of Jonas Schmedtmann's Node.js course, and wow, what a game-changer! Here's what I learned, why it was valuable, and how I plan to apply these concepts to my band's website.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Power of Mongoose Schemas
&lt;/h2&gt;

&lt;p&gt;One of the key concepts I dove into was Mongoose schemas. I learned how schemas define the structure of data in MongoDB collections. By using schemas, you can enforce rules for the data, such as requiring specific fields, setting default values, and even applying validation rules.  &lt;/p&gt;

&lt;p&gt;For example, I created schemas for documents like users, tours, and reviews. On my band’s website, I’ll apply this by defining schemas for &lt;strong&gt;users (fans and band members)&lt;/strong&gt;, &lt;strong&gt;album data&lt;/strong&gt;, &lt;strong&gt;comments&lt;/strong&gt;, and &lt;strong&gt;show schedules&lt;/strong&gt;. Setting clear rules ensures that all data entered into the site remains consistent and valid.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Schemas give your data structure and make it easier to debug issues early on.  &lt;/p&gt;




&lt;h2&gt;
  
  
  2. Virtual Properties and Indexes
&lt;/h2&gt;

&lt;p&gt;Virtual properties were a revelation—they let you define properties that aren’t stored in the database but can be dynamically calculated. For my band’s website, I plan to create virtual properties like &lt;strong&gt;"fan since"&lt;/strong&gt;, which calculates the length of time a user has been part of our community, based on their signup date.  &lt;/p&gt;

&lt;p&gt;Indexes will be a huge boost for performance, especially for fields like &lt;strong&gt;band member names&lt;/strong&gt; or &lt;strong&gt;album titles&lt;/strong&gt;. They’ll make searches and queries much faster.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Virtuals and indexes make your app faster and more dynamic without overcomplicating your database.  &lt;/p&gt;




&lt;h2&gt;
  
  
  3. Advanced Query Features
&lt;/h2&gt;

&lt;p&gt;I’ve gained confidence in using Mongoose middlewares and aggregation pipelines, which I’m excited to implement on the website.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mongoose Middlewares&lt;/strong&gt;: These will help me automate processes like updating timestamps for band members' profiles when they post new content.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aggregation Pipelines&lt;/strong&gt;: This will allow me to calculate stats like the &lt;strong&gt;most popular albums based on user favorites&lt;/strong&gt; or the &lt;strong&gt;average ratings of shows&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; These advanced tools will make the band’s site more interactive and user-focused.  &lt;/p&gt;




&lt;h2&gt;
  
  
  4. Referencing and Embedding Data
&lt;/h2&gt;

&lt;p&gt;I learned how to link data using &lt;strong&gt;referencing&lt;/strong&gt; and &lt;strong&gt;embedding&lt;/strong&gt;. For my band’s site, this means:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Referencing&lt;/strong&gt;: Connecting user profiles to their comments, favorite songs, or photos.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embedding&lt;/strong&gt;: Storing static data, like a setlist for a concert, directly in the show document for quick access.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By combining these strategies, I can make the site both flexible and efficient.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Choosing the right relationship strategy helps balance flexibility and performance.  &lt;/p&gt;




&lt;h2&gt;
  
  
  5. Using Data Validation to Improve Data Quality
&lt;/h2&gt;

&lt;p&gt;Data validation is essential for creating a smooth user experience. On my band’s website, I’ll use built-in validators to ensure:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Emails are valid&lt;/strong&gt; when fans sign up for accounts.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usernames follow proper guidelines&lt;/strong&gt; for band members and fans.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comments&lt;/strong&gt; don’t exceed a certain character limit to maintain readability.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Custom validators will also come into play, like making sure event dates don’t overlap or song titles aren’t duplicated.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Validation helps keep the data clean and the user experience smooth.  &lt;/p&gt;




&lt;h2&gt;
  
  
  How This All Fits Into My Band’s Website
&lt;/h2&gt;

&lt;p&gt;My band’s website will showcase tracks, albums, and upcoming shows while giving fans a space to interact with us. Here’s how I’ll integrate these features:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fans can &lt;strong&gt;sign up and comment&lt;/strong&gt; on albums or shows, with their data validated and securely stored using Mongoose.
&lt;/li&gt;
&lt;li&gt;Band members will have &lt;strong&gt;personal profiles&lt;/strong&gt; where they can share bios, photos, and updates, linked dynamically using referencing.
&lt;/li&gt;
&lt;li&gt;Albums and songs will have &lt;strong&gt;ratings and favorite counts&lt;/strong&gt;, calculated using aggregation pipelines.
&lt;/li&gt;
&lt;li&gt;Show details and setlists will be efficiently modeled and served to fans, making navigation fast and seamless.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Completing this course section has equipped me with the tools to make all these features come to life.  &lt;/p&gt;




&lt;h2&gt;
  
  
  6. Challenges and Growth
&lt;/h2&gt;

&lt;p&gt;What stood out most to me was how every feature I learned builds toward making an application more efficient, secure, and user-friendly. While some concepts (like aggregation) felt tricky at first, working through real-world examples gave me the confidence to start using them in my own projects.  &lt;/p&gt;




&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;As I build the band's website, I’ll continue applying these Mongoose techniques to ensure it’s reliable, scalable, and fun to use. This is just the beginning of combining my skills as a developer with my passion for music.  &lt;/p&gt;

&lt;p&gt;If you’re also learning Node.js or MongoDB, I highly recommend diving into these concepts—they’re challenging but rewarding!  &lt;/p&gt;

&lt;p&gt;Feel free to share your thoughts, tips, or even just tell me about your own projects. I’d love to connect and grow together!  &lt;/p&gt;




&lt;p&gt;If you’re interested in connecting or following my journey, feel free to check out my profiles:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/jahend412" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.linkedin.com/in/joshua-endemann/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading!&lt;/strong&gt;  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Authentication and Security in Web Development: Lessons Learned and Implementation Plans</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Sun, 01 Dec 2024 23:58:02 +0000</pubDate>
      <link>https://dev.to/jahend412/authentication-and-security-in-web-development-lessons-learned-and-implementation-plans-27e5</link>
      <guid>https://dev.to/jahend412/authentication-and-security-in-web-development-lessons-learned-and-implementation-plans-27e5</guid>
      <description>&lt;p&gt;Over the past few weeks, I’ve been diving deep into the &lt;strong&gt;authentication and security&lt;/strong&gt; section of Jonas Schmedtmann’s Node.js course. This experience has given me invaluable insights into securing modern web applications, and I’m excited to apply this knowledge to my band’s website as part of my portfolio project. In this blog, I’ll discuss what I’ve learned, why it’s important, and how I plan to implement these practices.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Key Lessons on Authentication and Security
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. The Fundamentals of Authentication
&lt;/h3&gt;

&lt;p&gt;Authentication is the process of verifying a user’s identity. From the course, I learned about:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Password hashing&lt;/strong&gt;: Hashing passwords using algorithms like bcrypt ensures that even if the database is compromised, passwords remain secure.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JWTs (JSON Web Tokens)&lt;/strong&gt;: These are widely used for user authentication in stateless systems. They enable secure communication between the client and server without storing session data on the server.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OAuth and third-party login&lt;/strong&gt;: For seamless user experiences, integrating services like Google or Facebook login is often preferred.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Authorization and Access Control
&lt;/h3&gt;

&lt;p&gt;Once a user is authenticated, the next step is determining what they’re allowed to do. Some highlights include:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Role-based access control (RBAC)&lt;/strong&gt;: Defining roles like “admin” or “user” to restrict access to specific resources.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API protection&lt;/strong&gt;: Using middleware to guard sensitive routes against unauthorized access.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Data Validation and Sanitization
&lt;/h3&gt;

&lt;p&gt;Unvalidated inputs are one of the biggest security risks. I learned how to:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validate user input with tools like Joi or express-validator.
&lt;/li&gt;
&lt;li&gt;Sanitize inputs to prevent attacks such as SQL injection or cross-site scripting (XSS).
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Password Reset Mechanisms
&lt;/h3&gt;

&lt;p&gt;Secure password reset functionality involves:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generating time-sensitive reset tokens.
&lt;/li&gt;
&lt;li&gt;Sending reset links via email securely (using Nodemailer).
&lt;/li&gt;
&lt;li&gt;Implementing additional checks, like IP logging, to detect unusual activity.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Rate Limiting and Brute Force Protection
&lt;/h3&gt;

&lt;p&gt;Tools like &lt;code&gt;express-rate-limit&lt;/code&gt; and &lt;code&gt;helmet&lt;/code&gt; play a key role in safeguarding against brute force attacks. They limit repeated requests from the same IP, making it harder for attackers to guess login credentials.  &lt;/p&gt;

&lt;h3&gt;
  
  
  6. Secure App Configuration
&lt;/h3&gt;

&lt;p&gt;Best practices in configuring a secure Node.js app include:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Storing sensitive data in environment variables.
&lt;/li&gt;
&lt;li&gt;Using libraries like &lt;code&gt;dotenv&lt;/code&gt; to manage configurations.
&lt;/li&gt;
&lt;li&gt;Setting secure HTTP headers with &lt;code&gt;helmet&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How I’m Applying This to My Band’s Website
&lt;/h2&gt;

&lt;p&gt;For my band’s website, security will be a top priority. While the primary focus will be on showcasing our music and events, I’ll also include features like user accounts for fans, ticket purchases, and possibly even an admin dashboard.  &lt;/p&gt;

&lt;p&gt;Here’s how I plan to integrate what I’ve learned:  &lt;/p&gt;

&lt;h3&gt;
  
  
  1. User Authentication with JWTs
&lt;/h3&gt;

&lt;p&gt;I’ll use &lt;strong&gt;JWTs&lt;/strong&gt; for a seamless and secure login experience. Fans will be able to create accounts to save favorite tracks, join newsletters, or purchase tickets. Admins will have additional access to manage event schedules and inventory.  &lt;/p&gt;

&lt;h3&gt;
  
  
  2. Password Security
&lt;/h3&gt;

&lt;p&gt;User passwords will be hashed with &lt;strong&gt;bcrypt&lt;/strong&gt; before being stored in the database. I’ll also include a robust &lt;strong&gt;password reset system&lt;/strong&gt; to make it user-friendly yet secure.  &lt;/p&gt;

&lt;h3&gt;
  
  
  3. Role-Based Authorization
&lt;/h3&gt;

&lt;p&gt;I’ll implement &lt;strong&gt;RBAC&lt;/strong&gt; to ensure:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fans can only access general features like track downloads or event booking.
&lt;/li&gt;
&lt;li&gt;Admins can update event details, manage ticket sales, and upload media files.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Secure Payment Gateway
&lt;/h3&gt;

&lt;p&gt;For ticket purchases, I’ll integrate a third-party payment service like Stripe. I’ll ensure that all payment data is handled securely with HTTPS and strict backend validation.  &lt;/p&gt;

&lt;h3&gt;
  
  
  5. API Rate Limiting
&lt;/h3&gt;

&lt;p&gt;To protect the site from potential brute-force or DDoS attacks, I’ll use &lt;code&gt;express-rate-limit&lt;/code&gt; to cap the number of login attempts and safeguard APIs.  &lt;/p&gt;

&lt;h3&gt;
  
  
  6. Data Validation and Sanitization
&lt;/h3&gt;

&lt;p&gt;Every form submission (e.g., signups, ticket bookings, or feedback) will be validated and sanitized to prevent injection attacks and maintain data integrity.  &lt;/p&gt;

&lt;h3&gt;
  
  
  7. Secure Deployment
&lt;/h3&gt;

&lt;p&gt;I’ll deploy the application using a platform like Vercel or AWS with HTTPS enabled and all sensitive environment variables securely managed.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;In today’s web landscape, users expect fast, functional, and—above all—&lt;strong&gt;secure&lt;/strong&gt; applications. By implementing strong authentication and security measures, I can provide a trustworthy experience for users while building my own confidence as a developer.  &lt;/p&gt;

&lt;p&gt;For my band’s website, it’s not just about protecting data but also about delivering an experience where users feel safe engaging with our platform. As this project progresses, I’m looking forward to combining my passion for music with my growing expertise in web development.  &lt;/p&gt;

&lt;p&gt;Stay tuned for updates!  &lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Learning authentication and security has been a transformative experience. It’s empowering to know that I can build not just functional but also secure web applications. With these practices in place, I’m confident my band’s website will stand out both as a showcase of our music and as a professional-grade portfolio project.  &lt;/p&gt;

&lt;p&gt;If you’re working on a web app and want to discuss authentication or security practices, feel free to reach out! I’d love to collaborate and learn even more.  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Error Handling in Node.js</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Thu, 21 Nov 2024 21:00:37 +0000</pubDate>
      <link>https://dev.to/jahend412/error-handling-in-nodejs-41o2</link>
      <guid>https://dev.to/jahend412/error-handling-in-nodejs-41o2</guid>
      <description>&lt;h1&gt;
  
  
  A Deeper Dive of my notes
&lt;/h1&gt;

&lt;p&gt;Error handling is an essential part of building robust and reliable applications. Throughout my learning journey in the Node.js course by Jonas Schmedtmann on Udemy, I've gained valuable insights into how errors can be managed more effectively in a Node.js application. In this post, I'll explain some of the key error-handling techniques I've implemented to improve both development and production environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Custom Error Class: &lt;code&gt;AppError&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;One of the first things I learned was the importance of creating a custom error class to handle errors in a structured way. By extending the built-in &lt;code&gt;Error&lt;/code&gt; class, we can create errors that carry additional properties such as the status code and a flag indicating whether the error is operational or not.&lt;/p&gt;

&lt;p&gt;For example, an error in my application can carry a message, a status code, and a status (whether the error is a "fail" or "error"). The &lt;code&gt;isOperational&lt;/code&gt; flag helps differentiate between trusted operational errors (such as a user validation failure) and unexpected programming errors. This custom error class allows for standardized error responses and makes the error-handling process more efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Centralized Error Handling Middleware
&lt;/h2&gt;

&lt;p&gt;In any Express-based application, error handling needs to be centralized to ensure consistency across the application. By implementing a dedicated error-handling middleware, I was able to handle errors uniformly for both development and production environments.&lt;/p&gt;

&lt;p&gt;In development, the error handler provides detailed information about the error, including the stack trace, which is valuable for debugging. However, in production, we avoid exposing sensitive error details to end users. Instead, the system sends a simplified error message, ensuring the user isn't overwhelmed with technical information. This helps protect sensitive application details while still providing helpful feedback when something goes wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Handling Asynchronous Errors with Middleware
&lt;/h2&gt;

&lt;p&gt;Asynchronous operations like database queries and API calls can often result in errors that are not handled properly. Without proper error handling, unhandled promise rejections can crash the application or cause it to behave unexpectedly.&lt;/p&gt;

&lt;p&gt;To address this, I implemented a middleware that wraps all asynchronous route handlers in my application. This middleware automatically catches any errors from async operations and passes them to the next error-handling middleware. This approach eliminates the need to manually handle each asynchronous error in every route, simplifying the code and making it more maintainable.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Custom Error Handling for Database Issues
&lt;/h2&gt;

&lt;p&gt;When working with databases, errors can arise from various situations such as invalid IDs, duplicate fields, and validation issues. I added custom handling for these errors to provide meaningful feedback to the user.&lt;/p&gt;

&lt;p&gt;For example, when an invalid ID is provided in a request, the application returns a specific message indicating that the ID is invalid. Similarly, when a user tries to submit a value that already exists in the database (like an email address), the application returns a helpful message suggesting an alternative. This approach improves the user experience by clearly pointing out what went wrong and how they can fix it.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Handling Unhandled Promise Rejections
&lt;/h2&gt;

&lt;p&gt;Unhandled promise rejections are a common issue in Node.js applications, where a promise is rejected but the error isn't properly handled. This can lead to the application failing silently or behaving unexpectedly. To prevent this, I added a global handler for unhandled promise rejections. When such an error occurs, the application logs the error details and shuts down the server gracefully. This ensures that the application does not crash suddenly and that resources are cleaned up before exiting.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Handling Uncaught Exceptions
&lt;/h2&gt;

&lt;p&gt;Uncaught exceptions (errors that are thrown and not caught anywhere in the application) can also cause the application to crash or behave unpredictably. To handle this, I set up a global handler for uncaught exceptions. When an uncaught exception occurs, the application logs the error details and shuts down the server cleanly. This ensures that the application terminates properly, freeing up resources and preventing memory leaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;These techniques have helped me handle errors more effectively and have given me a better understanding of how to build more resilient Node.js applications. As I continue to learn and implement more advanced concepts, I’ll be able to refine and expand my error-handling strategies further.&lt;/p&gt;

&lt;p&gt;By having a centralized error-handling system and addressing common issues like unhandled promise rejections and database errors, I've been able to create a more stable and user-friendly application. I'll start to incorporate this into my band's website and I will keep improving my error-handling strategies as I move forward with my Node.js journey.&lt;/p&gt;

&lt;p&gt;Next up I will be learning how to incorporate Users into the two projects.  Can't wait!!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Overcoming Challenges with GridFSStorage Integration</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Thu, 21 Nov 2024 02:25:28 +0000</pubDate>
      <link>https://dev.to/jahend412/overcoming-challenges-with-gridfsstorage-integration-5032</link>
      <guid>https://dev.to/jahend412/overcoming-challenges-with-gridfsstorage-integration-5032</guid>
      <description>&lt;p&gt;Yesterday, I spent some time learning about Document, Query, and Aggregation Middleware, as well as validators in MongoDB. Feeling accomplished, I decided to shift gears back to developing my band’s website. My next task seemed straightforward: enabling my database to handle larger files using GridFSStorage. &lt;/p&gt;

&lt;h2&gt;
  
  
  Diving In: Research and Initial Setup
&lt;/h2&gt;

&lt;p&gt;I began by researching the necessary tools and installed &lt;strong&gt;multer&lt;/strong&gt;, &lt;strong&gt;gridfs-storage&lt;/strong&gt;, and &lt;strong&gt;gridfs-stream&lt;/strong&gt;. With the documentation in hand, I created a utility file for configuring Multer. Next, I moved on to my route handler and implemented a new &lt;code&gt;POST('/upload')&lt;/code&gt; route. What seemed simple quickly spiraled into a larger, more complex task. &lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging: The Unexpected Roadblocks
&lt;/h2&gt;

&lt;p&gt;My first hurdle came with the persistent error:&lt;br&gt;&lt;br&gt;
&lt;code&gt;upload.single is not a function&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;After some investigation, I traced the issue back to my MongoDB connection. To resolve this, I moved the GridFSStorage setup into my &lt;code&gt;server.js&lt;/code&gt; file to ensure proper initialization. With that adjustment, I resolved this particular error and was able to move forward.&lt;/p&gt;

&lt;p&gt;However, as I tested file uploads via Postman, another issue arose:&lt;br&gt;&lt;br&gt;
&lt;code&gt;TypeError: Cannot read properties of undefined (reading '_id')&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;This error baffled me. Console logging the file details revealed that the file was being created, but something was missing. Despite hours of troubleshooting, I couldn’t pinpoint the exact cause. &lt;/p&gt;

&lt;h2&gt;
  
  
  A Breakthrough: The Power of Community
&lt;/h2&gt;

&lt;p&gt;After two exhausting days working in Wisconsin’s harsh weather and nights spent debugging, I turned to Stack Overflow. Within minutes, I found the solution: the version of MongoDB I was using wasn’t compatible with GridFSStorage. Downgrading to a compatible version solved the issue almost instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reflection and Moving Forward
&lt;/h2&gt;

&lt;p&gt;This experience, though frustrating, turned out to be a valuable learning opportunity. It reinforced the importance of persistence and effective debugging. I documented the challenges and solutions in my coding journal, ensuring I’ll have a reference for future projects.&lt;/p&gt;

&lt;p&gt;Looking ahead, I plan to dive deeper into error handling and tools like the &lt;strong&gt;ndb debugger&lt;/strong&gt; as part of the Natours project. Meanwhile, for my band’s app, I’ll revisit the roadmap to determine the next priority. The journey of learning and building continues, and I’m ready to hit the drawing board again.  &lt;/p&gt;

&lt;p&gt;Sometimes, the path to progress is rocky, but it’s all part of the process.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Today’s Progress: Adding an Aggregate Pipeline</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Tue, 19 Nov 2024 01:41:28 +0000</pubDate>
      <link>https://dev.to/jahend412/todays-progress-adding-an-aggregate-pipeline-97b</link>
      <guid>https://dev.to/jahend412/todays-progress-adding-an-aggregate-pipeline-97b</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Today, I focused on learning about the &lt;strong&gt;Aggregate Pipeline&lt;/strong&gt; through the &lt;strong&gt;Natours project&lt;/strong&gt; from a course on Udemy. The Aggregate Pipeline is a powerful tool for processing data in MongoDB, and I can see its significant value in various backend projects. Through the Natours project, I was able to implement aggregate pipelines for &lt;strong&gt;tour statistics&lt;/strong&gt; and create a &lt;strong&gt;monthly plan&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Creating Tour Stats and the Monthly Plan&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To get started, the instructor used an async function wrapped in a try-catch block to handle errors. For the &lt;strong&gt;tour stats&lt;/strong&gt;, an aggregate pipeline was implemented using the &lt;code&gt;Tour.aggregate&lt;/code&gt; method. The pipeline first &lt;strong&gt;matched&lt;/strong&gt; the documents based on a minimum rating average, followed by a &lt;strong&gt;group&lt;/strong&gt; stage that computed statistics like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of tours&lt;/li&gt;
&lt;li&gt;Number of ratings&lt;/li&gt;
&lt;li&gt;Average rating&lt;/li&gt;
&lt;li&gt;Average price&lt;/li&gt;
&lt;li&gt;Minimum price&lt;/li&gt;
&lt;li&gt;Maximum price&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The results were then &lt;strong&gt;sorted&lt;/strong&gt; based on the average price in ascending order. &lt;/p&gt;

&lt;p&gt;For the &lt;strong&gt;monthly plan&lt;/strong&gt;, the instructor set up a &lt;code&gt;year&lt;/code&gt; variable by extracting the year from &lt;code&gt;req.params.year&lt;/code&gt;, converting it into a number, and passing it into the pipeline. The pipeline started by &lt;strong&gt;unwinding&lt;/strong&gt; the &lt;code&gt;startDates&lt;/code&gt; array to output a document for each individual date. A &lt;strong&gt;match&lt;/strong&gt; stage was added to filter tours within the specified year, with &lt;code&gt;$gte&lt;/code&gt; (greater than or equal to) for the start of the year and &lt;code&gt;$lte&lt;/code&gt; (less than or equal to) for the end of the year. The pipeline then &lt;strong&gt;grouped&lt;/strong&gt; the documents by month and calculated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The number of tour starts&lt;/li&gt;
&lt;li&gt;The names of the tours (which were pushed into an array)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Afterward, the &lt;strong&gt;addFields&lt;/strong&gt; stage was used to add a field for the month, and the results were &lt;strong&gt;sorted&lt;/strong&gt; by the number of tour starts in descending order (&lt;code&gt;-1&lt;/code&gt; for descending). Finally, the results were &lt;strong&gt;limited&lt;/strong&gt; to 12 months, showing data for a year.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Takeaways&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Aggregate Pipeline&lt;/strong&gt; is undoubtedly an invaluable tool for backend development, particularly when dealing with large datasets that require complex queries and calculations. By using aggregation, I was able to extract meaningful insights from data, which will be extremely helpful for any future projects.&lt;/p&gt;

&lt;p&gt;I’ve already practiced using the aggregate pipeline in my &lt;strong&gt;merchController.js&lt;/strong&gt; for my band's website. Going forward, I'll experiment with more pipelines as I continue to build and refine my backend. One challenge I'll face is adding &lt;strong&gt;recording files&lt;/strong&gt; to the tracks database and grouping them into &lt;strong&gt;albums&lt;/strong&gt;, which will require careful planning and data modeling.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Next Steps&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Having integrated the aggregate pipeline into my &lt;strong&gt;merchController&lt;/strong&gt;, I plan to take a short break from this feature. Over the next few days, I'll focus on expanding my data sets, particularly by adding recording files for my band's tracks and determining the best way to group them into albums.&lt;/p&gt;

&lt;p&gt;Additionally, I’ll continue working on the &lt;strong&gt;Natours project&lt;/strong&gt; to further hone my skills with new tools and features. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Today was a productive learning day. As a developer with a family, I strive to make the most of my time. Recently, I’ve been maximizing my 1-hour commute to and from work by listening to the Udemy course. This allows me to absorb the lessons while spending time with my wife and kids at home. While listening and reviewing the content is helpful, &lt;strong&gt;practice&lt;/strong&gt; remains key to reinforcing what I've learned.&lt;/p&gt;

&lt;p&gt;Feel free to check out my GitHub repository for this project, and don’t hesitate to connect with me.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Today’s Progress: Implementing APIFeatures</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Mon, 18 Nov 2024 00:10:25 +0000</pubDate>
      <link>https://dev.to/jahend412/todays-progress-implementing-apifeatures-42hd</link>
      <guid>https://dev.to/jahend412/todays-progress-implementing-apifeatures-42hd</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Today, I focused on implementing APIFeatures in my band's website. This functionality includes filtering, sorting, pagination, field limiting, and aliasing. I gained these skills from a Udemy course and applied them step by step to enhance my project. &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Creating Sample Data&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To start, I created a variety of products in my &lt;code&gt;merchController&lt;/code&gt;. These included a Din hat, shirt, sweatshirt, CD, and vinyl. Each item had unique attributes such as different quantities and prices. This allowed me to test each feature against a realistic dataset and ensure my implementation worked as intended.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step-by-Step Implementation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Initially, I built all the features directly within the &lt;code&gt;merchController.js&lt;/code&gt; file. As I worked, I tested each feature using Postman to verify its functionality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Filter:&lt;/strong&gt; Allowed querying products by attributes like price or quantity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sort:&lt;/strong&gt; Enabled sorting by attributes such as price or date created.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pagination:&lt;/strong&gt; Broke down results into manageable pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Field Limiting:&lt;/strong&gt; Returned only specified fields in the response to reduce payload size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alias:&lt;/strong&gt; Created an alias route (&lt;code&gt;/top-5-merch&lt;/code&gt;) to display the cheapest merchandise.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once all the features were functional, I refactored my code. I extracted the logic into a reusable &lt;code&gt;APIFeatures.js&lt;/code&gt; utility file located in a &lt;code&gt;utils&lt;/code&gt; folder. This improved the structure and readability of my code. I then imported &lt;code&gt;APIFeatures&lt;/code&gt; into &lt;code&gt;merchController.js&lt;/code&gt; and cleaned up the controller by replacing inline logic with modular methods from &lt;code&gt;APIFeatures&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Key Takeaways&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;While refactoring, I learned how to effectively use &lt;code&gt;this.query&lt;/code&gt; and &lt;code&gt;this.queryString&lt;/code&gt; in place of &lt;code&gt;req.query&lt;/code&gt; and &lt;code&gt;query&lt;/code&gt;. This approach made the code more reusable and modular. I also revisited how to use Postman to test features, entering various query parameters to confirm the functionality of my code.&lt;/p&gt;

&lt;p&gt;Additionally, I implemented an alias for the route &lt;code&gt;/top-5-merch&lt;/code&gt;. This feature displays the cheapest merchandise in the database. Moving forward, I plan to incorporate similar aliases in other controllers. For instance, I envision creating a "top tracks" feature to showcase the most-played or most-liked songs once fans can "like" tracks.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Next Steps&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now that I have integrated APIFeatures, I will continue learning through my Natours project. Practicing new concepts from the course in both projects has proven to be an effective way to solidify my understanding. I will keep building on this foundation and add new features as I progress.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Today’s work was a significant step toward making my band's website more robust and user-friendly. By focusing on practical application and refactoring, I improved both the functionality and maintainability of my project. I’m excited to continue this journey and further enhance my skills.&lt;/p&gt;

&lt;p&gt;Feel free to check out my GitHub repository for this project &lt;a href="https://github.com/jahend412/din-ballyhoo" rel="noopener noreferrer"&gt;here&lt;/a&gt;, and don’t hesitate to connect with me!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Week in Review: Progress on My Band’s Web Application Backend</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Sat, 16 Nov 2024 15:21:48 +0000</pubDate>
      <link>https://dev.to/jahend412/week-in-review-progress-on-my-bands-web-application-backend-1i92</link>
      <guid>https://dev.to/jahend412/week-in-review-progress-on-my-bands-web-application-backend-1i92</guid>
      <description>&lt;p&gt;This week, I focused on building the backend for my band’s web application. My primary tasks included developing routes, defining schema models, and setting up controllers, all while successfully connecting the application to a MongoDB Atlas database.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Challenges and Solutions&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;One of the initial hurdles I faced involved troubleshooting naming inconsistencies across exports and imports. Through debugging, I resolved these issues by carefully aligning names in my codebase.&lt;br&gt;&lt;br&gt;
Another significant challenge was connecting the app to the MongoDB database. After some investigation, I discovered that the &lt;code&gt;&amp;lt;PASSWORD&amp;gt;&lt;/code&gt; placeholder in my &lt;code&gt;config.env&lt;/code&gt; file didn’t match the &lt;code&gt;&amp;lt;password&amp;gt;&lt;/code&gt; key referenced in the &lt;code&gt;server.js&lt;/code&gt; file. Once corrected, the connection was established successfully.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Progress So Far&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;With the connection in place, I tested the endpoints using Postman. I started with the merchandise routes, as they were straightforward to validate. I then tested and documented all available endpoints for the &lt;strong&gt;Albums&lt;/strong&gt;, &lt;strong&gt;Merch&lt;/strong&gt;, &lt;strong&gt;Shows&lt;/strong&gt;, &lt;strong&gt;Webcasts&lt;/strong&gt;, and &lt;strong&gt;Tracks&lt;/strong&gt; models.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Current Focus&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;I am currently implementing advanced API features to enhance functionality, including:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sorting
&lt;/li&gt;
&lt;li&gt;Filtering
&lt;/li&gt;
&lt;li&gt;Advanced filtering
&lt;/li&gt;
&lt;li&gt;Field limiting
&lt;/li&gt;
&lt;li&gt;Pagination
&lt;/li&gt;
&lt;li&gt;Aliasing
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Next Steps&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once the API features are complete, I will shift my focus to user authentication. My plan includes creating separate sign-up and login functionality for both fans and band members. Additionally, I will address error handling and begin refactoring my code to adhere to the DRY (Don’t Repeat Yourself) principle, improving maintainability and readability.&lt;/p&gt;

&lt;p&gt;This week has been productive, with significant progress made in laying a strong foundation for the application. I’m excited to continue refining and expanding the project in the coming weeks!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>mongodb</category>
      <category>learning</category>
      <category>api</category>
    </item>
    <item>
      <title>Building a Music-Focused Web App for my band: Progress and Next Steps</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Thu, 14 Nov 2024 01:54:02 +0000</pubDate>
      <link>https://dev.to/jahend412/building-a-music-focused-web-app-for-my-band-progress-and-next-steps-5e67</link>
      <guid>https://dev.to/jahend412/building-a-music-focused-web-app-for-my-band-progress-and-next-steps-5e67</guid>
      <description>&lt;p&gt;Over the past few days, I’ve made significant progress on a web app designed for my band, where users can sign in, explore albums and live shows, download music, donate, and learn more about the band. This project is built with the MERN stack (MongoDB, Express, React, and Node.js), and I’m excited to share the new features I’ve been working on.&lt;/p&gt;

&lt;p&gt;Recent Progress: Band Member &amp;amp; Fan Features&lt;br&gt;
One of the main areas I’ve been focusing on is building out the core models and controllers for the app. These structures are key to ensuring smooth functionality as users interact with the app. Here’s what’s new:&lt;/p&gt;

&lt;p&gt;Band Member Authentication: I’ve set up a bandMember.js model, which stores the band members' information like their name, role, and instrument. This model also supports authentication, so band members can log in securely using their credentials. The app uses JWT tokens for secure logins, ensuring that only authorized band members can access sensitive data like tour dates, setlists, and upcoming shows.&lt;/p&gt;

&lt;p&gt;Fan Authentication: Fans can also create an account to log in and interact with the band’s content. The Fan.js model stores fan profiles, including favorite albums, shows they’ve attended, and other personalized details. Fans will eventually be able to interact more deeply with the app, such as commenting on shows, albums, and webcasts, and even liking tracks and performances.&lt;/p&gt;

&lt;p&gt;Interactive Features for Fans: Fans won’t just be passive viewers of the app. I plan to implement features where they can like and comment on tracks, albums, live shows, and webcasts. This will allow them to engage more with the band’s content and become part of the community. These interactions will be stored and displayed on their profiles, and eventually, fans will be able to follow specific albums or shows to receive notifications about updates.&lt;/p&gt;

&lt;p&gt;Webcast and Show Controllers: I’ve also been working on controllers for webcasts and shows. Webcasts will allow fans to tune in to live broadcasts of events, while the show controller will manage concert details, including tour dates, venues, and setlists. These features will help fans stay up to date with the band's live performances.&lt;/p&gt;

&lt;p&gt;Keeping the Code DRY&lt;br&gt;
A major focus for me has been ensuring that the code remains clean, efficient, and easy to maintain. This means reducing repetition and focusing on reusable code. To achieve this, I’ve:&lt;/p&gt;

&lt;p&gt;Centralized Error Handling: I’ve implemented an error handling middleware that consolidates all error management into one place, making the codebase more manageable and ensuring that errors are handled consistently across the app.&lt;/p&gt;

&lt;p&gt;Reusable Validation Middleware: Input validation has been standardized using middleware to ensure that all data passed into the app is correct and well-formed. This reduces the need to repeat validation logic in every route handler.&lt;/p&gt;

&lt;p&gt;By making these improvements, I can add new features without bloating the code and keep everything manageable as the app scales.&lt;/p&gt;

&lt;p&gt;Next Steps&lt;br&gt;
Looking ahead, there are several key features I plan to work on next:&lt;/p&gt;

&lt;p&gt;User Authentication (JWT): I will be refining the user authentication system for both fans and band members to ensure a smooth and secure experience.&lt;/p&gt;

&lt;p&gt;Like and Comment Features: As mentioned, I plan to allow fans to interact with tracks, shows, albums, and webcasts by liking and commenting on them. This will help build a more engaging community around the band.&lt;/p&gt;

&lt;p&gt;Testing and Bug Fixes: Once these features are integrated, I’ll focus on testing the app to ensure everything works as expected. I’ll also tackle any bugs or performance issues that arise during testing.&lt;/p&gt;

&lt;p&gt;User Notifications: Fans will eventually be able to receive notifications about new shows, webcasts, or album releases. I’ll be implementing a system for sending notifications based on their preferences.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
The app is coming together nicely, and I’m excited about the features on the horizon. By building a robust, interactive platform, I’ll be able to provide a deeper connection between the band and our fans. Stay tuned for more updates as I continue to build out the app, and I look forward to sharing more in the near future!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring MVC Architecture and Applying It to My Natours Project</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Mon, 28 Oct 2024 01:54:57 +0000</pubDate>
      <link>https://dev.to/jahend412/exploring-mvc-architecture-and-applying-it-to-my-natours-project-1p6d</link>
      <guid>https://dev.to/jahend412/exploring-mvc-architecture-and-applying-it-to-my-natours-project-1p6d</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction to MVC Architecture&lt;/strong&gt;&lt;br&gt;
Today, I delved deeper into the Model-View-Controller (MVC) pattern, a fundamental design structure for organizing code in web applications. The core purpose of MVC is to separate the app’s components into three main areas, ensuring that each part has a single, focused responsibility. By understanding and implementing MVC, I’m not only making my project more manageable but also laying the foundation for future scalability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Breaking Down MVC&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Request Initiation:&lt;/strong&gt;&lt;br&gt;
Every interaction starts with a client request to the server, triggering the MVC process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Router:&lt;/strong&gt;&lt;br&gt;
The router intercepts this incoming request and directs it to the correct controller based on the defined route and request type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Controller:&lt;/strong&gt;&lt;br&gt;
Acting as a central coordinator, the controller processes the business logic and works with models to retrieve or modify data when necessary.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Model:&lt;/strong&gt;&lt;br&gt;
Models handle direct interactions with the database, taking care of any resource access or updates required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;View:&lt;/strong&gt;&lt;br&gt;
Once data is prepared by the controller, it is passed to the view layer. The view converts this data into a user-friendly format that the client will receive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Response:&lt;/strong&gt;&lt;br&gt;
The view is sent back to the client as the final response, completing the cycle.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In essence, this cycle demonstrates the MVC flow, promoting a clean separation of responsibilities and making data handling more efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Separating Application Logic and Business Logic&lt;/strong&gt;&lt;br&gt;
When organizing code with MVC, it’s crucial to differentiate between Application Logic and Business Logic, as they have distinct roles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application Logic:&lt;/strong&gt;&lt;br&gt;
Purpose: Handles the structural and technical aspects of the app, focusing on how the app functions without addressing the specific business problem it aims to solve.&lt;br&gt;
&lt;strong&gt;Responsibilities:&lt;/strong&gt;&lt;br&gt;
Managing requests and responses.&lt;br&gt;
Acting as an intermediary between models and views.&lt;br&gt;
Maintaining the app’s technical workflow and structure.&lt;br&gt;
&lt;strong&gt;Business Logic:&lt;/strong&gt;&lt;br&gt;
Purpose: Directly addresses the specific business problems the application is built to solve, enforcing business rules and workflows.&lt;br&gt;
&lt;strong&gt;Responsibilities:&lt;/strong&gt;&lt;br&gt;
Ensuring that business needs are accurately represented in the app.&lt;br&gt;
Enforcing business rules, such as:&lt;br&gt;
Validating user inputs.&lt;br&gt;
Creating new resources, like tours, in the database.&lt;br&gt;
Managing permissions for actions (e.g., allowing only users who’ve purchased a tour to leave reviews).&lt;br&gt;
Although there may be overlap, keeping application and business logic distinct is a powerful way to maintain a clean codebase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refactoring My Natours Project with MVC&lt;/strong&gt;&lt;br&gt;
In the Natours project, I began implementing MVC architecture by moving the tour schema and model into a separate tourModel.js file and assigning controller functions to manage business logic. This setup bridges the model and view layers with dedicated controller functions, organizing the project in a way that will make it much easier to expand and adapt in the future.&lt;/p&gt;

&lt;p&gt;Refactoring for MVC has already made the project more organized and scalable. This approach sets a solid foundation for handling future features, integrations, or even scaling the application without creating excessive complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
Revisiting MVC today has been a real eye-opener. Breaking down each layer has shown me just how crucial separating responsibilities is for keeping projects scalable and maintainable. This clarity in MVC is already helping me build out Natours with a more organized, adaptable structure—one that’ll be much easier to grow over time.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Working with MongoDB.</title>
      <dc:creator>Josh Endemann</dc:creator>
      <pubDate>Mon, 28 Oct 2024 01:05:22 +0000</pubDate>
      <link>https://dev.to/jahend412/working-with-mongodb-1ep0</link>
      <guid>https://dev.to/jahend412/working-with-mongodb-1ep0</guid>
      <description>&lt;p&gt;In the past week, I’ve been diving deeper into backend development for my Natours project. A key part of this journey has been learning about MongoDB and how to implement it effectively. The transition has been eye-opening, especially as I explore MongoDB’s flexibility and ease of use in handling data for web applications. Here’s a breakdown of my experience, challenges, and insights as I started integrating MongoDB into Natours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why MongoDB?&lt;/strong&gt;&lt;br&gt;
MongoDB is a popular choice for developers building applications where data structures may be flexible, and it’s particularly well-suited for projects where document-based storage is advantageous. MongoDB’s NoSQL model allows for scalability and easy adjustments, ideal for the kinds of dynamic and user-driven features I’m implementing in Natours. The more I learn about MongoDB, the more I appreciate its flexibility compared to traditional relational databases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up MongoDB Atlas and Compass&lt;/strong&gt;&lt;br&gt;
The first step was setting up MongoDB Atlas, a cloud database service that provides a fully-managed, scalable environment for MongoDB. Using Atlas makes it easy to get started without the need for a local installation, and it also comes with useful features like automated backups and monitoring tools.&lt;/p&gt;

&lt;p&gt;Here's a quick overview of my setup process:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Atlas Account Creation and Cluster Setup:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I created an account on MongoDB Atlas and set up my first cluster. The Atlas UI guided me through choosing a free tier, configuring basic settings, and creating a database user with secure authentication.&lt;br&gt;
Connecting to Atlas:&lt;/p&gt;

&lt;p&gt;Once the cluster was up, I generated a connection string that I would use in my application. The MongoDB Atlas dashboard allows users to create and customize these connection strings with options like specifying database names, authentication credentials, and network restrictions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Compass for Database Management:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I also installed MongoDB Compass on my Mac, which provides a GUI for exploring and managing MongoDB data locally. Compass has been a fantastic tool for visualizing the data structures, analyzing query performance, and even crafting complex queries as I refine the project’s backend.&lt;br&gt;
Integrating MongoDB with the Natours Project&lt;br&gt;
After setting up my database environment, the next step was to connect MongoDB to my project using the Mongoose ODM (Object Data Modeling) library. Here’s a look at how I implemented this integration:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuring Environment Variables:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I added the database connection details to a new config.env file in my project, ensuring sensitive information like credentials and database URLs stay secure. Environment variables are essential for securely managing application settings and configurations, and using them allows me to easily switch between different environments.&lt;br&gt;
Setting Up Server Connection:&lt;/p&gt;

&lt;p&gt;In my server.js file, I used the Mongoose connect method to establish the connection to the Atlas cluster. Here’s a snippet of how the connection code looks:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
Copy code&lt;br&gt;
const DB = process.env.DATABASE.replace(&lt;br&gt;
    '',&lt;br&gt;
    process.env.DATABASE_PASSWORD&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;mongoose.connect(DB, {&lt;br&gt;
    useNewUrlParser: true,&lt;br&gt;
    useCreateIndex: true,&lt;br&gt;
    useFindAndModify: false,&lt;br&gt;
    useUnifiedTopology: true,&lt;br&gt;
}).then(() =&amp;gt; &lt;br&gt;
    console.log('DB connection successful!')&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Creating the First Schema and Model:&lt;/p&gt;

&lt;p&gt;I started with a basic tour schema and model to represent tours within Natours. I defined fields like name, rating, and price, including validation rules to ensure data integrity. Here’s a simplified version of the schema setup:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
Copy code&lt;br&gt;
const tourSchema = new mongoose.Schema({&lt;br&gt;
    name: {&lt;br&gt;
        type: String,&lt;br&gt;
        required: [true, 'A tour must have a name'],&lt;br&gt;
        unique: true&lt;br&gt;
    },&lt;br&gt;
    rating: {&lt;br&gt;
        type: Number,&lt;br&gt;
        default: 4.5&lt;br&gt;
    },&lt;br&gt;
    price: {&lt;br&gt;
        type: Number,&lt;br&gt;
        required: [true, 'A tour must have a price']&lt;br&gt;
    }&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;const Tour = mongoose.model('Tour', tourSchema);&lt;br&gt;
Testing the Database Connection:&lt;/p&gt;

&lt;p&gt;To verify everything was working, I created a test tour entry with a save() method. This allowed me to confirm that my schema was correctly set up and that data was being stored as expected in MongoDB.&lt;br&gt;
&lt;strong&gt;Working with MongoDB’s Document Model&lt;/strong&gt;&lt;br&gt;
One of the standout aspects of MongoDB has been its document model, which allows data to be stored as flexible, schema-less documents. This makes it easy to adjust the structure as the project evolves without requiring extensive refactoring. Learning to work with MongoDB has taught me the importance of planning database schemas carefully, especially when handling relationships between data models in a NoSQL environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenges and Lessons Learned&lt;/strong&gt;&lt;br&gt;
As with any new technology, there have been challenges along the way. Some issues I encountered included:&lt;/p&gt;

&lt;p&gt;Deprecation Warnings: I encountered some deprecation warnings from Mongoose, which I resolved by adding options like useUnifiedTopology: true.&lt;br&gt;
Error Handling: Handling duplicate entries was another area where I had to adjust my code to avoid issues with MongoDB’s unique constraints.&lt;br&gt;
These experiences have improved my troubleshooting skills and taught me a lot about managing a NoSQL database effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Steps and Goals&lt;/strong&gt;&lt;br&gt;
I’m excited to continue building out Natours and applying what I’m learning about MongoDB and Mongoose. My next immediate step is to expand on the data models, adding new schemas and incorporating advanced Mongoose functionality like virtuals, query middleware, and data validation.&lt;/p&gt;

&lt;p&gt;After solidifying my backend knowledge, I’ll be moving on to frontend development, where I’ll dive deeper into React with Next.js to round out my full-stack skills.&lt;/p&gt;

&lt;p&gt;Having worked with MongoDB before, I’m excited to be diving back in and deepening my experience with this technology. It’s been great to get reacquainted with MongoDB, and I’m thrilled to be building more hands-on expertise as I integrate it into the Natours project. I am looking forward to documenting my experience as I continue to build the Natours project.  Stay tuned for more updates and feel free to reach out!!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
