Duration: 80 minutes
Learning Objectives
Understand and use middleware for enhanced functionality.
Handle static files and perform input validation.
Implement advanced middleware like authentication.
Topic Outline (30-min)
Middleware Essentials:
Role and execution flow.
Built-in vs. custom middleware.
Static File Serving:
Use middleware to serve static files.
Input Validation:
Validate request payloads using libraries like express-validator.
express-validator
Student Activity (30-min)
Activity: Implement Middleware for Validation
Homework/Practice Coding Assignment (20-min)
Task: Extend the API to:
Serve static HTML files for /home and /contact.
/home
/contact
Add middleware to log request time and method for all routes.
Last updated 1 year ago