
Build a backend for a blogging app with signup, email verification, article creation and listing (including unpublished), cookies for login, image uploads, and reactions like bookmarks and likes.
Unzip the app bundle, open in VSCode, review dependencies (express, sequelize, sqlite, nodemailer, multer, cookie-parser), install with npm install, and run npm run dev to start the server.
Implement the user signup flow with the signup endpoint, router, and database user entity, save the user, and trigger a welcome email for the signup success scenario.
Create a post /api/users endpoint for user sign up using an express router, parse the JSON body with express.json, and respond with a success message.
Initialize a Sequelize ORM with SQLite storage and sync the user model to the database. Define user attributes like email, handle, name, and image, and set timestamps to false.
Save the user to the database and send a signup email containing a login token via an ethereal fake smtp server, using node mailer.
Add maintenance functionality with a config folder to manage database and email configurations. Implement database migrations to control schema evolution rather than Sequelize auto-creating the database.
Learn to configure a blogging app for development and production by using a config package and cross-env, defining environment-specific database and email settings, and securing secrets with environment variables.
Learn to manage database schemas with Sequelize migrations, using the CLI to initialize config.js, set up migrations, and apply up and down changes to the user table.
Implement robust signup error handling by validating user input with express validator and custom logic, using a shared error handler and mapped exceptions, handling email failures, and rollback scenarios.
Ensure a unique handle by checking the user table for conflicts before saving. If needed, append a short id derived from the first UUID segment via a shared utility.
Learn to validate user input in a Node blog app using express validator, ensuring non-null, non-empty email before saving, and map validation errors to a clean 400 response.
Implement a generic Node error handler that maps errors to structured responses with status, message, path, timestamp, and validation details, integrated via middleware and app.use after routers.
Extract and share the validation logic with a parameterized schema and middleware, using express validator to validate request bodies, handle errors, and reuse across endpoints.
Wrap the user save in a try-catch, throw a validation exception for unique email errors, and route the message to the api error handler.
implement a custom unique email validator in a node blogging app by querying the user table before saving, enforcing email in use checks at the schema level.
Handle email delivery failures during user signup by returning an error, logging issues, and preventing database save when email fails, using a 502 bad gateway email exception.
Build the authentication functionality with a router and service, create a token entity stored in the database, and expose endpoints for authentication, login, and logout using a shared tokenization endpoint.
Implement the auth endpoint by creating an auth router and service, validating the registration token, updating the user, returning a DTO, and issuing an http-only app token cookie.
Validate user input for auth requests using a schema and validator; ensure token is not empty and operation is one of register or login, returning precise errors.
Implement an opaque, unique login token by creating a tokens table related to users, generating and storing the token with sequelize, and returning it to the user.
Implement logout by deleting the app token from the database using a post logout endpoint, read via cookies, clear the cookie, and ensure no token remains for the user.
Implement the login flow by generating a login token, emailing the sign-in link via the auth and user services, and validating existing users through the old router with error handling.
Extend the auth endpoint to support login with a login token via an operation parameter (register or login), build a where object, and issue an app token after token cleanup.
Create the article resource with endpoints for create, update, and publish, enforce user-article association via custom middleware, and verify that update or publish requests come from the article owner.
Create articles table with Sequelize migration, defining id, title, slug (unique), content, image, and published flag, with timestamps created_ add and updated_ add and a user_id key with cascade delete.
Define an article schema with express validator for title and content, and implement a router and service to save articles to the database and return the id and slug.
Implement a cookie token middleware that detects the user from the cookie, fetches the user from the token repository, and saves articles with the user's id.
Explore cookie management and authentication checks when no user is present, then implement a configurable middleware that returns 403 forbidden for authenticated endpoints and allows non required endpoints.
Implement article update functionality in the blogging app, validating article existence and ownership, updating title, content, and image, and returning the article id via a put endpoint.
Implement article publish functionality by toggling the published flag and published_at for a given article, using a patch endpoint /api/articles/{id}/publish and owner validation.
Add a get endpoint for listing articles, seed the database with published and unpublished articles using Sequelize CLI, and implement pagination using a middleware, Sequelize pagination query functionalities, and DTOs.
Seed a blog database with sqlite and the command line interface by creating a seed that generates 10 users, tokens, and five articles each using lorem ipsum content and slugs.
This lecture demonstrates building a paginated get articles endpoint in a blog app, filtering to published articles, and a reusable pagination middleware handling page, size, offset, and total pages.
Describe sorting of articles via sort and direction parameters, defaulting to descending order by id, with validation of sortable fields and a reusable get order function.
Create an article dto for listing articles without content, featuring a short article with id, title, slug, image, published, and author; implement a belongs-to user relation and an author dto.
Add a get article by id or slug endpoint that fetches a single article with content, determines id or slug, includes the user, and handles not found errors.
Limit visibility of unpublished articles to the owner by using an optional auth middleware, validating user ownership in the service, and returning not found for others or unauthenticated requests.
Learn to build an endpoint that lists a user's articles with optional unpublished content for the logged-in user, using id or handle, pagination, and shared query logic.
Implement a Node Express file upload system using Multer, with validation, file size limits, and type filtering, plus serving static files and configurable upload directories across environments.
Set up an Express file upload router using multer, saving to the upload folder, handling a single file from field 'file', and returning 201 with the file name.
Learn to validate file uploads in a blog app by enforcing a one megabyte size limit and jpeg/png mime type, using a custom validation exception and inline upload handling.
Serve static files with express static middleware from the upload directory at the api assets endpoint, enabling one-year browser caching via a shared constant.
Configure environment-specific upload directories with config, join root paths, and implement upload directory creation in a Node app; apply to static content and routing, then test dev and prod.
Add two new endpoints for updating and getting the user, offering hands-on practice for client-focused development.
Implement update user functionality with a secured, authenticated put endpoint at api/users/:id, validating name length and handling image data while enforcing ownership.
Add a get user endpoint to fetch a single user by handle. Return a user DTO or throw not found, and expose a non-authenticated route at api/users/:handle for client-side display.
Add a new reactions resource and endpoint to the blogging app, enabling reactions on articles and queries that summarize them, and filter articles by the logged-in user's reaction.
Create a reactions table with Sequelize migrations, defining id and category, plus user_id and article_id foreign keys with cascade delete; build reaction model and set up user and article associations.
Define a reaction schema to validate article reactions, including entity type, entity id, and category, then implement a toggle reaction endpoint that adds or removes the reaction.
Seed reactions by linking articles and users, assign a random category from the categories array to each article, and perform a bulk insert after migrating the database for testing.
Implement article reactions with counts for hot, like, and reading list, and indicate the current user's reaction. Integrate this into article retrieval, supporting optional user id and guest access.
Filter articles by the current user's reactions using a reaction query parameter and the get reacted articles endpoint, with pagination and user and reaction models.
Are you ready to take your Node JS skills to the next level by building a complete, real-world application from scratch? Welcome to "Portfolio Project: Blogging Application with Node JS"! This hands-on course is designed to provide you with practical experience in using Node JS to develop a fully functional blogging platform.
In this course, we focus on the practical implementation of Node JS, bypassing lengthy theoretical explanations. You'll dive straight into coding, using Sequelize for robust database interactions, including both simple and complex queries. We'll also cover essential migration functionalities to help you manage database schema changes efficiently.
Our application will be configured to run in multiple environments, ensuring that it is versatile and ready for production. You'll implement key features such as user authentication with sign-up and login functionalities, complete with email verification. All user requests will be rigorously validated to ensure security and reliability.
Centralized error handling will be another focus, helping you manage and debug errors effectively. The course will guide you through creating and managing articles, allowing authorized users to submit, update, or modify their published state. Additionally, you'll implement file upload functionality to handle static files seamlessly.
To enhance user engagement, we’ll include a reactions resource, enabling users to like or bookmark articles. Plus, you’ll get a client application to test and see your backend in action, ensuring a comprehensive learning experience.
This course aims to provide a complete understanding of building a robust application from start to finish. Whether you're a beginner or an experienced developer looking to refine your skills, this course has something for you. Join us now and start building something amazing with Node JS!