Express JS Assignment- 3
Basic Questions
- Install EJS, set it as Express’s view engine, and render a simple view that displays a dynamic variable “Hello, Template Engine!”.
- Install and configure EJS as the template engine in an Express project.
- Render a simple EJS template with a dynamic variable username.
- Create a layout.ejs and extend it in another template using EJS partials.
- Add a partial template header.ejs and include it in multiple pages.
- Create two routes, one rendering an EJS view and another rendering a Pug view, both displaying “Hello Templates!”.
- Create a Handlebars view that renders a list of items dynamically.
- Write a helper function in Handlebars to uppercase text.
- Render an HTML page using dynamic data for a products array.
- Create a page that displays the current date using a template engine.
- Create an EJS layout with a header and footer partial. Render two pages (home.ejs, about.ejs) sharing those partials to demonstrate reduced duplication.
- Create a /api/principles GET endpoint that returns a JSON array of 5 REST principles (like “Stateless”, “Cacheable”) dynamically as an API response.
- Create a simple GET route /api/users that returns a JSON array.
- Define versioned routes like /api/v1/users and /api/v2/users.
- Implement a POST route /api/users to add a user.
- Implement a PUT route /api/users/:id to update a user.
- Implement a DELETE route /api/users/:id to delete a user.
- Build one route /api/rest/users returning an array of users in JSON, and another route /api/graphql/users returning only selected fields.
- Test a GET request in Postman and verify the response.
- Install express-rate-limit and apply it globally to your Express app.
Intermediate Questions
- Create an EJS template with a loop to display a list of blog posts.
- Use EJS partials for header, footer, and navbar in a project.
- Demonstrate how layouts reduce code duplication in EJS.
- Create two routes, /pug-products to render products list using Pug and /hbs-products to render the same list using Handlebars.
- Render dynamic user data with Handlebars and a custom helper.
- Create a REST API /api/products with CRUD endpoints.
- Add pagination support to /api/products?page=1&limit=5.
- Add sorting support to /api/products?sort=price.
- Add filtering support to /api/products?category=electronics.
- Implement CRUD API with MySQL using mysql2 module.
- Implement CRUD API with MongoDB using mongoose.
- Implement CRUD API with PostgreSQL using pg module.
- Add centralized error-handling middleware for APIs.
- Return proper HTTP status codes for CRUD (200, 201, 404, 500).
- Create a custom error class ApiError and use it in routes.
- Standardize API error responses { success: false, message, code }.
- Use Postman to send POST request with JSON body.
- Use Postman to test error response from /api/unknown.
- Create custom error logging middleware that writes errors to a file.
- Apply rate limiting only to /api/login route.
Advanced Questions
- Build a blog app with EJS templates, using layouts and partials.
- Implement nested layouts in Handlebars (main.hbs > dashboard.hbs).
- Build a REST API /api/orders with full CRUD + pagination + filtering.
- Integrate MongoDB with Mongoose and add validation rules.
- Integrate PostgreSQL and implement parameterized queries for security.
- Create a global error-handling system with custom error classes + logger.
- Implement monitoring for API performance logs (response time, status).
- Write a middleware that returns 429 Too Many Requests after 5 failed requests/minute.
- Combine JWT authentication with rate limiting for secure APIs.
- Build a mini Express project:Template engine for UI