Express JS Assignment- 3

Basic Questions

  1. Install EJS, set it as Express’s view engine, and render a simple view that displays a dynamic variable “Hello, Template Engine!”.
  2. Install and configure EJS as the template engine in an Express project.
  3. Render a simple EJS template with a dynamic variable username.
  4. Create a layout.ejs and extend it in another template using EJS partials.
  5. Add a partial template header.ejs and include it in multiple pages.
  6. Create two routes, one rendering an EJS view and another rendering a Pug view, both displaying “Hello Templates!”.
  7. Create a Handlebars view that renders a list of items dynamically.
  8. Write a helper function in Handlebars to uppercase text.
  9. Render an HTML page using dynamic data for a products array.
  10. Create a page that displays the current date using a template engine.
  11. Create an EJS layout with a header and footer partial. Render two pages (home.ejs, about.ejs) sharing those partials to demonstrate reduced duplication.
  12. Create a /api/principles GET endpoint that returns a JSON array of 5 REST principles (like “Stateless”, “Cacheable”) dynamically as an API response.
  13. Create a simple GET route /api/users that returns a JSON array.
  14. Define versioned routes like /api/v1/users and /api/v2/users.
  15. Implement a POST route /api/users to add a user.
  16. Implement a PUT route /api/users/:id to update a user.
  17. Implement a DELETE route /api/users/:id to delete a user.
  18. Build one route /api/rest/users returning an array of users in JSON, and another route /api/graphql/users returning only selected fields.
  19. Test a GET request in Postman and verify the response.
  20. Install express-rate-limit and apply it globally to your Express app.

Intermediate Questions

  1. Create an EJS template with a loop to display a list of blog posts.
  2. Use EJS partials for header, footer, and navbar in a project.
  3. Demonstrate how layouts reduce code duplication in EJS.
  4. Create two routes, /pug-products to render products list using Pug and /hbs-products to render the same list using Handlebars.
  5. Render dynamic user data with Handlebars and a custom helper.
  6. Create a REST API /api/products with CRUD endpoints.
  7. Add pagination support to /api/products?page=1&limit=5.
  8. Add sorting support to /api/products?sort=price.
  9. Add filtering support to /api/products?category=electronics.
  10. Implement CRUD API with MySQL using mysql2 module.
  11. Implement CRUD API with MongoDB using mongoose.
  12. Implement CRUD API with PostgreSQL using pg module.
  13. Add centralized error-handling middleware for APIs.
  14. Return proper HTTP status codes for CRUD (200, 201, 404, 500).
  15. Create a custom error class ApiError and use it in routes.
  16. Standardize API error responses { success: false, message, code }.
  17. Use Postman to send POST request with JSON body.
  18. Use Postman to test error response from /api/unknown.
  19. Create custom error logging middleware that writes errors to a file.
  20. Apply rate limiting only to /api/login route.

Advanced Questions

  1. Build a blog app with EJS templates, using layouts and partials.
  2. Implement nested layouts in Handlebars (main.hbs > dashboard.hbs).
  3. Build a REST API /api/orders with full CRUD + pagination + filtering.
  4. Integrate MongoDB with Mongoose and add validation rules.
  5. Integrate PostgreSQL and implement parameterized queries for security.
  6. Create a global error-handling system with custom error classes + logger.
  7. Implement monitoring for API performance logs (response time, status).
  8. Write a middleware that returns 429 Too Many Requests after 5 failed requests/minute.
  9. Combine JWT authentication with rate limiting for secure APIs.
  10. Build a mini Express project:Template engine for UI