FA21-BCS-A Final Lab Exam

You are required to make a copy of your term project into a folder named final-lab-exam. In your Term Project you must have implemented a server side CRUD.

You are to implement a new Feature of Featured Products. Add a new model if not already exist

// models/product.js

const mongoose = require(‘mongoose’);

// Define the schema for a Product
const productSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
description: {
type: String,
required: true
},
price: {
type: Number,
required: true
},
category: {
type: String,
required: true
},
isFeatured: {
type: Boolean,
default: false
}
});

// Create the model from the schema
const Product = mongoose.model(‘Product’, productSchema);

module.exports = Product;

If your term project already has a product model then add isFeatured Flag.

Add some sample products and display 5 featured products on your homepage.

Add a new route /products/:id with get method and display a single product with that id on that route inside your layout.

if a visitor visit a product page then add that product id into session in an array called visitedProducts.

add a new route /visited-products and display visitor’s visited products on that page.
Commit your code before 5:30 PM