0% found this document useful (0 votes)
10 views2 pages

PROG3017 FullStack Lab3C

Uploaded by

absolutigahiga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

PROG3017 FullStack Lab3C

Uploaded by

absolutigahiga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab

PROG 3017 LAB 3C


FULL STACK PROGRAMMING

Prerequisites
 Postman or similar client ready to perform your actions against your endpoint.
 You’ll use your already created repository for Lab3B. You should have Lab3B already
completed and fully submitted (including your screencast video) before beginning this
portion of the lab.
 The accompanying class lecture.

Instructions
In continuing your exploration of Express JS and creating an API endpoint, complete the
following steps to add to your already created API from Lab 3B

Validation
 Using the Joi NPM package joi (https://www.npmjs.com/package/joi), create a function
called validatePerson() which receives a submitted person object and executes the
following validation on that object
o first_name – required, has a minimum length of 3 and a maximum length of 30
o last_name – required, has a minimum length of 3 and a maximum length of 30
o email – required and must be a valid email format
o job_title – optional, but when provided it must be one of the following values
 Structural Engineer
 Chief Design Engineer
 Desktop Support Technician
 Sales Associate
 Apply Validation to any endpoint that is deemed to require validation of submitted data.
 Modularize the function into its own .js file and demonstrate the importing of the module
using import and export (esmodules).

HTTP Response Codes


 Ensure that you have implemented all appropriate HTTP response codes for all of your
endpoints that reflect the following:
o Resource was successfully retrieved
o Unable to locate a resource
o Resource was successfully created
o Resource was successfully updated
o Resource was successfully deleted
o A validation error occurred

Middleware

Semester- Fall Year- 2024/2025 1 of 2


Lab
 Add and activate the third-party middleware package called morgan. Once installed
you’ll begin to see all of the requests made to your endpoints logged to the console.
 Create your own custom middleware function which uses the third-party npm package
called cookie-parser (https://www.npmjs.com/package/cookie-parser) (you’ll need to
install it) and console.logs any submitted cookie data to the console for all requests.
 Add your own dummy cookie value to postman for the domain localhost to test this
functionality. Postman should send along the cookie with every request it makes. You’ll
need to research how to set a cookie when sending a request from Postman.

Semester- Fall Year- 2024/2025 2 of 2

You might also like