Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Build a Node.js module that is designed to track inventory for a store. Build A

ID: 3806116 • Letter: B

Question

Build a Node.js module that is designed to track inventory for a store.

Build A Node.js module called inventory.js that exposes the following functionality:

addItem - A function that takes 2 parameters: an item’s name and price and tracks it internally.

items - A function that returns a list of items, sorted by price from least expensive to most expensive.

getMostExpensive - Returns an object that contains the item’s name and price for the most expensive item that has been added.

getLeastExpensive - Returns an object that contains the item’s name and price for the most least expensive item that has been added.

removeItem - Remove an item by name.

getItemByName - Returns an item’s name and price by name.

getItemByPrice - Returns an item’s name and price by price.

Your module should not expose any functions or variables that would allow the above functions to have the integrity of their data compromised.

NOTES:

* Cannot use any third party JavaScript libraries

* Must use JavaScript’s strict mode

* Must use let instead of var

Explanation / Answer

var CT = require('./modules/country-list');
var AM = require('./modules/account-manager');
var EM = require('./modules/email-dispatcher');

module.exports = function(app) square measure saved in an exceedingly cookie //
       if (req.cookies.user == indefinite || req.cookies.pass == undefined));
       }   elsetry automatic login //
           AM.autoLogin(req.cookies.user, req.cookies.pass, function(o)   else);
               }
           });
       }
   });
  
   app.post('/', function(req, res)   else);
                   res.cookie('pass', o.pass, );
               }
               res.status(200).send(o);
           }
       });
   });
  
// logged-in user homepage //
  
   app.get('/home', function(req, res) isn't logged-in send back to login page //
           res.redirect('/');
       }   else);
       }
   });
  
   app.post('/home', function(req, res)   else, function(e, o)   else{
                   req.session.user = o;
           // update the user's login cookies if they exists //
                   if (req.cookies.user != indefinite && req.cookies.pass != undefined){
                       res.cookie('user', o.user, );
                       res.cookie('pass', o.pass, );  
                   }
                   res.status(200).send('ok');
               }
           });
       }
   });

   app.post('/logout', function(req, res));
   })
  
// making new accounts //
  
   app.get('/signup', function(req, res) );
   });
  
   app.post('/signup', function(req, res), function(e)   else
       });
   });

// arcanum reset //

   app.post('/lost-password', function(req, res)find the user's account via their email //
       AM.getAccountByEmail(req.body['email'], function(o)recall takes a flash to come //
               // TODO add associate Ajax loader to allow user feedback //
                   if (!e)   else{
                       for (k in e) console.log('ERROR : ', k, e[k]);
                       res.status(400).send('unable to dispatch arcanum reset');
                   }
               });
           }   else
       });
   });

   app.get('/reset-password', function(req, res) volt-ampere email = req.query["e"];
   power unit passH = req.query["p"];
       AM.validateResetLink(email, passH, function(e) else{
   // save the user's email in an exceedingly session rather than causing to the shopper //
               req.session.reset = ;
               res.render('reset', );
           }
       })
   });
  
   app.post('/reset-password', function(req, res) volt-ampere nPass = req.body['pass'];
   // retrieve the user's email from the session to operation their account and reset arcanum //
   power unit email = req.session.reset.email;
   // destory the session instantly when retrieving the hold on email //
       req.session.destroy();
       AM.updatePassword(email, nPass, function(e, o){
           if (o)   else
       })
   });
  
// read & delete accounts //
  
   app.get('/print', function(req, res) );
       })
   });
  
   app.post('/delete', function(req, res));
           }   else
   });
   });
  
   app.get('/reset', function(req, res) );
   });
  
   app.get('*', function(req, res) ); });

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote